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.
To exclude first and second element from jQuery, use the slice() method.
The not() is an inbuilt function in jQuery which is just opposite to the filter() method. This function will return all the element which is not matched with the selected element with the particular “id” or “class”. The selector is the selected element which is not to be selected.
Try:
$('img.lazy').not('.notlazy')
There are a few other ways...
$('img.lazy:not(.notlazy)')
$('img.lazy').filter(function() {return !$(this).hasClass('notlazy');});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With