Is there a way of checking whether the object's specific class is in array - I've done it with object's 'id', but can't do with 'class' - with 'id' it goes like this:
var arr = [ 'error', 'button', 'items', 'basket' ];
if (jQuery.inArray($(this).attr('id'), arr) == -1) {
// do something here
}
I would like to have something like the following, which doesn't work:
var arr = [ 'error', 'button', 'items', 'basket' ];
if (jQuery.inArray($(this).attr('class'), arr) == -1) {
// do something here
}
Any idea?
Just to show you what I'm using it for:
var arr = [ 'error', 'button', 'items', 'basket' ];
$.each(data, function(k, v) {
if (jQuery.inArray($(this).attr('class'), arr) == -1 && $('.' + k).length > 0) {
$('.' + k).fadeOut(100, function() {
$(this).hide().html(v).fadeIn(100);
});
}
});
hasClass. Where is the problem?