Live() keyword not working on load with dynamic html images
- by Sara Chipps
I have images being dynamically added to a page, I don't seem to be able to get the 'load' event working dynamically with live().
This is the code I currently have:
$('#largeImg' + nextUniqueItemID).hide();
$('#largeImg' + nextUniqueItemID).live('load' , function() {
$('#loader' + nextUniqueItemID).hide();
$('#largeImg' + nextUniqueItemID).show();
});
with '#largeImg' + nextUniqueItemID being an image that was added to the page earlier in the function and '#largeImg' + nextUniqueItemID being a loading image.
I feel as if I may be misusing "live" as it doesn't really need a listener but to trigger the event immediately.