Live() keyword not working on load with dynamic html images

Posted by Sara Chipps on Stack Overflow See other posts from Stack Overflow or by Sara Chipps
Published on 2010-06-15T08:33:22Z Indexed on 2010/06/15 8:52 UTC
Read the original article Hit count: 200

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about load