如果此代码中元素中的元素已存在,如何阻止重新出现元素?
SonarQube Configuration Manager
现在我想像这样思考
<div class='weekHourValue' data-nameDay='Tuesday' data-week='34' data-day='10' data-month='5' data-year='2015'><div class='singleYearEvent'></div></div>
<div class='weekHourValue' data-nameDay='Tuesday' data-week='34' data-day='10' data-month='5' data-year='2016'></div>
有这样的jquery函数吗?谢谢!
答案 0 :(得分:2)
您可以尝试:
$(".weekHourValue[data-month='5'][data-day='10']").each(function(){
if (!$(this).find(".singleYearEvent").length)
$(this).append("<div class='singleYearEvent'></div>");
});