I have this jquery that catch link url (this link is an image) and simple show this image. My problem is the loading. I want to show LOADING and hide it when the image is completely loaded. but I can't because my new image has no class and I don't not how to check if it is done.
How can I show and hide this loading properly?
js
$(function() {
$(".p").click(function(e){
e.preventDefault();
var element = $(this);
var I = element.attr("href");
$("#loading").show(); //SHOW LOADING
$("#imgfull").empty();
var img = $("<img/>").attr("src", I); // add new image
$("#imgfull").append(img); // add new image
$('#???').load(function(){
//$("#loading").hide(); //hide loading?????
})
});
});
html
<a href="http://ilikewall.com/wp-content/uploads/2015/04/3d_wallpapers_hd.jpg" class="p">click to load</a>
<div id="loading">LOADING</div>
<div id="imgfull"></div>
thank you