jQuery hasClass() - check for more than one class

Solution 1:

element.is('.class1, .class2')

works, but it's 35% slower than

element.hasClass('class1') || element.hasClass('class2')

JSperf chart showing .hasClass() is faster than .is()

See also this jsbench.me test.

Solution 2:

How about:

element.is('.class1, .class2')

Solution 3:

$.fn.extend({
    hasClasses: function (selectors) {
        var self = this;
        for (var i in selectors) {
            if ($(self).hasClass(selectors[i])) 
                return true;
        }
        return false;
    }
});

$('#element').hasClasses(['class1', 'class2', 'class3']);

This should do it, simple and easy.