Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple selector with filter

Tags:

jquery

Is there a way to combine a multiple selector and a basic filter within a single query?

For example...

var jq = $(someElement);

// Want to find the first following sibling node which has either classA or classB.

// This imaginary jquery does not quite work.
jq.nextAll("(.classA, .classB):first") 

// This works. But I wonder if I can achieve the same result with just one query.
jq.nextAll(".classA, classB)").filter(":first")
like image 888
Kei Avatar asked Jul 31 '26 17:07

Kei


1 Answers

what if you do .first() instead of .filter(":first") ?

Does that help ?

like image 78
TarasB Avatar answered Aug 02 '26 07:08

TarasB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!