element.is('.class1, .class2')
works, but it’s 35% slower than
element.hasClass('class1') || element.hasClass('class2')
See also this jsbench.me test.
More Related Contents:
- What is the fastest method for selecting descendant elements in jQuery?
- jQuery select by class VS select by attribute
- Performance of jQuery selector with context
- Performance of jQuery selectors vs local variables
- jQuery how to find an element based on a data-attribute value?
- Why is my jQuery :not() selector not working in CSS?
- Wildcards in jQuery selectors
- Set select option ‘selected’, by value
- What is fastest children() or find() in jQuery?
- Jquery bind double click and single click separately
- jQuery OR Selector?
- jQuery selector value escaping
- jQuery or CSS selector to select all IDs that start with some string [duplicate]
- jquery find versus context selection
- How can I detect if a selector returns null?
- What CSS3 selectors does jQuery really support, e.g. :nth-last-child()?
- jQuery: select an element’s class and id at the same time?
- Difference between :hidden and :not(:visible) in jQuery
- jQuery attribute name contains
- jQuery scrollTop not working in Chrome but working in Firefox
- First word selector
- jQuery attribute selector for multiple values
- Find all elements based on ids using regex on jQuery selector
- A cleaner way to select by multiple possible attribute values?
- How to select specific form element in jQuery?
- Using jQuery how do I select a range of rows?
- How to select a table column with jQuery
- jQuery animate() and browser performance
- How to use multiple jquery object variables as selectors?
- Can jQuery selectors be used with DOM mutation observers?