[jQuery] class 찾기
·
👩🏻‍💻STUDY/jQuery
[jQuery] class 찾기 hasClass() is() length apple banana orange 1.hasClass() 선택자 태그에 해당 조건이 class 이여야 한다. 태그는 안되는 것 같다. // jQuery $('.wrap > div').each(function() { if($(this).hasClass('apple')) { // true $(this).css({color: 'red'}); } else { // false $(this).css({color: 'yellow'}); } }) 2.is() 특정 클래스를 포함하고 있는지, class외에 id, name 등도 사용가능하다. 클래스 이름 앞에 .을 찍어서 클래스 속성임을 명..