Content of the jquery access loaded via the ajax call

advertisements

i'm trying to write a jquery plugin that when i click on a image to pop an alert message. Those images are loaded via load() method. Is there possible to load the plugin on document ready and the plugin to have acces to the loaded content? i don't want to use a callback function, i just want to include the plugin in the html page and then the plugin do it's thing.


If I understand you correctly, you probably want to use the jQuery.live method to bind an onClick handler to all present AND future images that conform to a query. For example, you can say

$("img.alerting").live("click", function(){
    alert("This image's src is " + this.src);
});

And then every image with the "alerting" class will always have a click handler, even images that didn't exist when you ran the above code.