each循环,字符串拼接及截取
// 定义关注领域拼接id var focusAreasIdStr = ''; $("div[name='focusArea']").each(function() { var falg = $(this); if ($(this).hasClass("choose-box-item-blue")) { focusAreasIdStr += falg.attr("id") + ','; } }); focusAreasIdStr = focusAreasIdStr.substring(0, focusAreasIdStr.length - 1);