❤️jQuery根据div的name属性和样式判断each循环,字符串拼接及截取

小明的学习圈子2023-08-13前端总结 循环 字符串操作

js根据div的name属性和样式判断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);
Last Updated 2024/4/6 10:47:15