Frank
Frank

Reputation: 1056

Jquery select all images except those with a certain class

I am trying to use lazyload on a page.

The code i have is:

$(function() {
    $("img.lazy").lazyload();
});

However i want it to ignore all images that have the class "notlazy". How do i put a condition in the selector?

Thanks in advance, sorry for this primitive question.

Upvotes: 14

Views: 19873

Answers (1)

sje397
sje397

Reputation: 41822

Try:

$('img.lazy').not('.notlazy')

There are a few other ways...

$('img.lazy:not(.notlazy)')
$('img.lazy').filter(function() {return !$(this).hasClass('notlazy');});

Upvotes: 34

Related Questions