Apply Jquery Code On All Elements
how can I apply a jquery function to elements that are loaded with ajax? TestTest<
Solution 1:
jQuery's live()
is what you'll want:
$('.h').live('click', function () {
// Do something!
}
Solution 2:
The click()
function only adds a listener to the elements present at th time it was called. You need to call it again on any element, you add later on.
Or, as @jerluc stated, use the live()
function.
Solution 3:
You must use live instead of click, so that the event is binded also to newly appended items:
$('.h').live('click', function() {
alert("test");
});
Solution 4:
You need the live
function to bind the event to elements created dynamically:
$('.h').live('click', function() {
alert("test");
});
Solution 5:
You aren't reapplying the behaviour. You need to use jQuery's live method to keep checking the DOM for new elements.
Post a Comment for "Apply Jquery Code On All Elements"