[jQuery] $('.class1,.class2').filter(':first') always finds first .class1
Basically, what I want to do is find the first element that matches
either class1 OR class2. However, using the syntax from the subject
line:
var $jqElem = $('.class1,.class2').filter(':first');
$jqElem is always the first element that has class1 (i.e., the first
class specified), rather than the first element for the whole
selector. E.g., using the above on the following:
<input type="text" id="elem1" class="class2" />
<input type="text" id="elem2" class="class1" />
it is getting "elem2."
Am I using the wrong syntax? I also tried $
('.class1').add('.class2').filter(':first'), but I get the same
result.
Thanks,
Pyro