Quantcast
Channel: Marius' Blog » JavaScript jQuery
Viewing all articles
Browse latest Browse all 4

How can you trigger an event in JavaScript (using jQuery) when an image is completely loaded

$
0
0

This JavaScript code will trigger an event when an image is completely loaded. You need to have the jQuery Library.

JavaScript code:

var img = new Image();

$(img).load(function(){
    $(imageContainer).html(this); // Add the image in the document.
    // Add any event …                
}).error(function(){
    // No image event …  
}).attr("src", imagePath);


Viewing all articles
Browse latest Browse all 4

Trending Articles