Solved

Jquery success image loaded

Posted on 2014-11-14
2
159 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now