I can only think of somehow circumventing to use grouped selectors,
e.g. search by class (which is ugly probably):

$('.find-me').eq(0).addClass('found-it');

or search by universal selector and filter by type afterwards:

$('body *').filter('h2, h4, p, ul').eq(0).addClass('found-it');

Not sure if that yields the desired result... and how good it would
perform.


--Klaus



On 4 Jun., 22:11, andjules <[EMAIL PROTECTED]> wrote:
> this is not a surprise... it is right in the docs:
>
> >http://docs.jquery.com/Selectors/multiple#selector1selector2selectorN
> > "Note order of the dom elements in the jQuery object aren't
> > necessarily identical."
>
> BUT, I need to match a handful of things and add to the first match in
> the DOM, e.g.:
> $('h2,h4,p,ul').eq(0).addClass('found-it');
>
> unfortunately, it looks for all h2 THEN all h4 THEN all p THEN all ul,
> instead of scanning the dom for matches in the order of the DOM...
>
> So my question is: how would I achieve this: find the first match for
> multiple selectors, as it appears in the DOM?
>
> Thanks

Reply via email to