Jquery success image loaded

Hi E's, I have this code to know if the image have any error when loaded:
jQuery(function($) { 
 $("#logo img,#home img,#contact img").error(function() { 
var which_one = $(this).attr("src");
alert(which_one+" fail"); 

Open in new window

If I want to know if the image was successfully load, what changes I have to do?

Th best regards, JC
Pedro ChagasWebmasterAsked:
Who is Participating?
Alexandre SimõesConnect With a Mentor Manager / Technology SpecialistCommented:
Use the load event handler:
jQuery(function ($) {
    $("#logo img,#home img,#contact img")
        var which_one = $(this).attr("src");
        alert(which_one + " success");
    .error(function () {
        var which_one = $(this).attr("src");
        alert(which_one + " fail");

Open in new window

Pedro ChagasWebmasterAuthor Commented:
Muito obrigado.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.