how to use Jquery functions on Dynaically created elements having IDs
I have created some elements dynamically and now i have to add datepicker and开发者_开发问答 use jquery function on them so how can i do that.
Make use of jquery live() function
$('.clickme').bind('click', function() {
// Bound handler called.
});
example
$('a').live({
click: function() {
// do something on click
},
mouseover: function() {
// do something on mouseover
}
});
Use .on() method and attach listener to an event from a contaiber. Example:
$('body').on('click', 'a.someclass', function() {})
This will bind the function() to all 'a' elements witg classe 'someclass' that are children of 'body', using the concept of event delegation.
精彩评论