select element with jquery using a criteria on element child class -
i have dom :
<div class=main> <div class="child"></div> </div> <div class=main> <div class="child b"></div> </div> <div class=main> <div class="child"></div> </div> <div class=main> <div class="child b"></div> </div>
i select jquery main div element has child without class "b". getting first , third element. have done , it's not working, returns me elements :
$(".main").not(".b")
i have tried this, throws me exception "invalid token" :
$(".main").not(":.b")
thanks in advance
you need use combine :not
, :has
selector:
$('.main:not(:has(".b"))');
or find child element not have class b , traverse such elements parent using .parent()
selector:
$('.child:not(".b")').parent()
Comments
Post a Comment