Solved

Jquery success image loaded

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
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…

776 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