Solved

Jquery success image loaded

Posted on 2014-11-14
2
169 Views
Last Modified: 2014-11-14
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
0
Comment
Question by:Pedro Chagas
2 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 40442547
Use the load event handler:
jQuery(function ($) {
    $("#logo img,#home img,#contact img")
    .load(function(){ 
        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

0
 
LVL 3

Author Closing Comment

by:Pedro Chagas
ID: 40443176
Muito obrigado.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question