I want the image to be displayed only after it's fully loaded. How can I do that?
<ul id="listcontainer">
<li class="li1">
<img src="images/m1.png">
</li>
</ul>
I want the image to be displayed only after it's fully loaded. How can I do that?
<ul id="listcontainer">
<li class="li1">
<img src="images/m1.png">
</li>
</ul>
You could play with the document.ready and window.load events as window.load fires when all your images are loaded.
$(document).ready(function(){
$("img").hide();
});
$(window).load(function(){
$("img").show();
});
You could try this
Put this in your css #listcontainer{ opacity:0; }
$(document).ready(function(){
$('#listcontainer').animate({
opacity: '1'
},500);
});
If you really want to hide the images you could use .css and display:none;
Put this in your css #listcontainer{ display:none; }
$(document).ready(function(){
$('#listcontainer').css(
'display', 'block'
);
});
I think you can do something like this:
<script>
document.addEventListener('DOMContentLoaded', function(){
var img = document.createElement("img");
img.src = "images/m1.png";
var src = document.getElementsByClassName("li1");
src.appendChild(img);
}, false);
</script>