반응형
jQuery에 클래스 선택기가 없습니다.
특정 클래스의 요소를 선택하지 않는 단순한 셀렉터 표현식이 있습니까?
<div class="first-foo" />
<div class="first-moo" />
<div class="first-koo" />
<div class="first-bar second-foo" />
난 그냥 처음 세 개의 divs를 얻어서 시도했어
$(div[class^="first-"][class!="first-bar"])
그러나 마지막 div가 first-bar보다 많은 값을 포함하므로 이 값은 모두 수신됩니다.플레이스 홀더를 그런 식으로 사용할 수 있는 방법이 있나요?그런 거.
$(div[class^="first-"][class!="first-bar*"]) // doesn't seem to work
도움이 될 만한 다른 선택기가 있나요?
셀렉터가 필요합니다.
$('div[class^="first-"]:not(.first-bar)')
또는 다음 방법.
$('div[class^="first-"]').not('.first-bar');
를 사용할 수 있습니다.:not
필터 선택기:
$('foo:not(".someClass")')
또는not()
방법:
$('foo').not(".someClass")
상세 정보:
jQuery 실렉터는 "not" 메서드로 작성할 수 있습니다.
$('div[class^="first-"]').not($('.first-bar'))
또한 다음 jQuery 이벤트에서도 작동합니다.:not()
셀렉터
간단하게 다음과 같습니다.
jQuery(document).on('click', '.fo-line:not(.deleted) .clickable', function(e) {
e.preventDefault();
// do your stuff...
});
제 경우, 모든 클릭을 유효하게 합니다.<td class="clickable">
의<tr class="fo-line">
모든 것이 기대되다deleted
클래스(<tr class="fo-line deleted">
)
언급URL : https://stackoverflow.com/questions/4614120/not-class-selector-in-jquery
반응형
'programing' 카테고리의 다른 글
Pattern Syntax Exception:Java에서 regex를 사용할 때 잘못된 반복 (0) | 2022.09.24 |
---|---|
MySQL에서 IN 절 매개 변수 목록 비우기 (0) | 2022.09.24 |
"새로운 사일런트 종료" 중단점이클립스 + 스프링 부트의 예외()" (0) | 2022.09.24 |
Maria를 사용한 SHA-256 비밀번호 생성DB (0) | 2022.09.24 |
Python의 SFTP(플랫폼에 의존하지 않음) (0) | 2022.09.24 |