开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜