开发者

how to use Jquery functions on Dynaically created elements having IDs

开发者 https://www.devze.com 2023-02-14 23:33 出处:网络
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

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

精彩评论

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