How to just extend selector from $(this) to, lets say, it's children? Or to anything else. I mean, how to properly contcatenate them with $(this)?
Like:
$("li.nav").each(function() {
$(this AND children of this, or this AND it's siblings).something();
});
Sorry if this was already answered, couldn't find it.
You can use andSelf
to accomplish this:
$(this).children().andSelf().something();
You can also use .end
to pop the last filtering operation off of the current chain. So if you wanted children and siblings, you could accomplish that too:
$(this)
.children() // children of "this"
.end() // now we're back to "this"
.siblings() // siblings of "this"
.andSelf() // and "this" itself
.something();
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