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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -