Solved

Jquery success image loaded

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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.
The viewer will learn how to dynamically set the form action using jQuery.
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)

706 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

19 Experts available now in Live!

Get 1:1 Help Now