I have the following if statement in a jQuery script that checks if an image has a class of “ignore”, and if so it will ignore it. this is an image the script found earlier within a specific section of my page:
if(!$(this).hasClass('ignore')) {
//do something
}
How can I set this up so that I can store an array of classes, and then have the if statement check against that array?
Create an
Arrayas you normally would andpushwhichever classes you want to ignore.In your
ifstatement do a.not()selector and pass in yourArrayvalues by calling thejoinfunction.http://jsfiddle.net/hEsPd/1/