For a jquery plugin to work I have to set the img with the class lazy to display: none from CSS.
I know how to make it appear when I need it using jquery:
$("img.lazy").show();
The problem is that I am loading the jquery library in the footer and I need the image to appear when the page starts to load.
I cannot move the code to the header cause there is no jquery.
So I am thinking of doing it with javascript.
I have tried getElementbyID but I can’t make it work.
Any ideas?
You can use following to display all images with class name
lazyusingquerySelectorAllDEMO.
For single element you can use
querySelectorDEMO.
Browser compatibility for querySelector/querySelectorAll.
Alternative (runs in every browser)
DEMO.