I want to Pre-load two sprites images with jquery or JavaScript, These sprites image doesn't shows until page is fully loaded. i have tried this, this ,this, this and many more, but none of them works for me. However a simple CSS HTML based solution works. But I have many pages so I cannot use CSS HTML solution, Rather I want use some jquery solution so as to work in one single .js file that all page has access.
CSS Html based solution that works.
<div id="preload">
<img src='_ls-global/images/layout-images/layout.png'/>
<img src='_ls-global/images/layout-images/layout2.png'/>
</div>
<style>
#preload{ display: none;}
</style>
As this CSS HTML based solution is working, i implemented it using jQuery like this but it is not working.
$(window).load(function(){
$("<div/>", {
"id": "preload",
"css": { "display" : "none"},
}).prependTo("body");
$("<img src='_ls-global/images/layout-images/layout.png'/>").appendTo("#preload");
$("<img src='_ls-global/images/layout-images/layout2.png'/>").appendTo("#preload");
});
Please suggest any possible way to do it.
Thanks.