jquery .live on load event
- by bandhunt
I need a way to use the jquery .live() function to act on elements that are loaded via ajax.
For instance a div is loaded via ajax .load()
<div id="mydiv"></div>
Normally I do .live() with a click event, but I need to know how to tell the dom that this new div has loaded without any explicit actions/events from the user.
This code doesn't work, but I want to do something like this:
mydiv = $("#mydiv");
mydiv.live("mydiv.length > 0", function() {
// do something
});
The "mydiv.length" being a substitue for the typical "click" or other event.