williamsandonz
williamsandonz

Reputation: 16420

jQuery selector, get elements with no class type A and no ancestors have class type A

I need a custom selector which grabs all LI's who do not have the class hiddenField and who have no ancestors with the class hiddenField

E.G

var lis= $f.find('li:not(.hiddenField)').filter('andAncestorsHaveNoClassHiddenField)

Bit stretched for me :)

Upvotes: 1

Views: 111

Answers (2)

ahren
ahren

Reputation: 16961

$f.find("li:not('.hiddenField')").filter(function(){
    return !$(this).parents().hasClass(".hiddenField"); 
})

Upvotes: 2

zerkms
zerkms

Reputation: 254886

$f.find('li:not(.hiddenField) :not(.hiddenField)').parent()

Upvotes: 1

Related Questions