I am wondering if there is a way to have "OR" logic in jQuery selectors. For example, I know an element is either a descendant of an element with class classA or classB, and I want to do something like elem.parents('.classA or .classB')
. Does jQuery provide such functionality?
views:
1895answers:
1It should be noted this isn't really an 'or' selector, more like multiple selectors in one.
alex
2010-02-15 03:57:03
@alex: but it won't select the same element twice (which a concatenation operator would). It really is an OR selector because it creates a UNION of two or more sets (whereas AND is an intersection).
cletus
2010-02-15 03:59:36
Thanks, that works. Because of a debugging oversight I thought that using a comma means 'AND'.
Suan
2010-02-15 04:00:18
`AND` would be `.classA.classB`.
Daniel A. White
2010-02-15 04:28:14
@cletus Thanks. I didn't think of it on that level. Though I don't doubt you are correct.
alex
2010-02-15 04:40:13