Jquery Lazy Loading after image load, css is not applied
I would suggest doing it this way :
$('img.lazy').Lazy({
scrollDirection: 'vertical',
visibleOnly: false,
afterLoad: function(element) {
element.css('border', 'thick solid chartreuse');
}
});
By using border
you won't be missing any parameters! :) Also less code to do the same thing is always better.
I prepared a demo with a large file and a loading animation so you could actually notice the lazy loading before the image loads and the border takes effect.
JSFiddle demo
Border-style
CSS attribute is required. Default value is none
, so border is not displayed.
$('img.lazy').Lazy({
scrollDirection: 'vertical',
visibleOnly: false,
afterLoad: function(element) {
element.css('border-width', 'thick');
element.css('border-color', 'chartreuse');
// add border-style and border becomes visible
element.css('border-style', 'solid');
}
});
Live demo