trying to exclude a set of elements from the matched set when it's parent object has a cetain class.
current solution is:
$("#pages li a").not($(this).parent().hasClass('no-script'))
but this is not behaving as I would expect, what am I doing wrong?
You want to use a :not()
selector on the parent, like this:
$("#pages li:not(.no-script) a")
If there many be multiple levels, make sure it's the current level's parent by using a child selector (>
):
$("#pages li:not(.no-script) > a")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With