2
어쩌면 이걸 잘못 이해하고 있지만이 상황에서 작동하지 않아야합니까? 내가 도대체 뭘 잘못하고있는 겁니까?jQuery는 의도 한대로 작동하지 않습니다.
$("#count").on("click", function(){
$(".item").each(function(index, element){
$(element).text(index + 1);
/*** this line does nothing ****/
$(element).has(".special").css("background", "black");
if(index + 1 == 4 || index + 1 == 8){
$(this).css("background", "#A5C663");
}
})
})
HTML :
<div id="grid">
<div class="item"></div>
<div class="item special"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item special"></div>
<div class="item"></div>
</div>
이 것은 하나 작동하지 않습니다 :
$(this).has(".special").css("background", "black");
또는 :
$(".item).has(".special").css("background", "black");
에 관한 요소의 설정에 관한 것입니다. 예를 들어 ".item"안에 "special"클래스가있는 단락을 추가합니다. 고맙습니다. 그것이 나를 허용 할 때. – Sergi