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")
not sure exactly what you’re trying to do, but if you just wanted the innerhtml of the first element you should be able to do something like:
since html will act on the first matched element.
Otherwise, i don’t see what is wrong with your method that works… I suppose you’re just asking for additional knowledge?
I never find much need for the :first selectorbut i would probably do this like: