> > Your issue doesn't actually have anything to do with the filter, it's > > the selection. $('.class1,.class2') selects all class1, then all > > class2. > > This totally explains why I have the issue, and I thank you for > describing it. I expected the select element statement to behave > something like, "className ~= /^(?:class1|class2)$/," but it really > operates more like, "(.class1).push(.class2)."
In fact, there's even a comment about this in the docs: http://docs.jquery.com/Selectors/multiple#selector1selector2selectorN "Note order of the dom elements in the jQuery object aren't necessarily identical." However, this seem to do what you want, albeit probably a little slower: $('*').filter(function() {return $(this).is('.class1,.class2');})...; Though you should probably use something a little more specific than * as the initial selector. Maybe ':input' to search all inputs, or '#myForm *' or '#myForm :input' to only search children of your form. Hope it helps. --Erik