开发者

Use markitup or masked input plugin (for example) on several elements, created after page loading?

开发者 https://www.devze.com 2023-01-15 13:44 出处:网络
Here is a small example with the masked input plugin : //apply the mask to an input $(\'.st\').live(\'click\', function() {

Here is a small example with the masked input plugin :

//apply the mask to an input
$('.st').live('click', function() {
  $(this).mask("99:99");
});

.st is a text input with a td, the use can clone the td. However, when you clone this td, and try to click in the .st of the new element, your gain the focus of 开发者_如何转开发the first .st and it's not working.

I have tried several things, bind(), live(), and each() with no results.


  1. New jQuery (since 1.3 or 1.4) can clone everything together with event bindings. See .clone() in documentation (supply true as a parameter)

  2. You can always write a function binding everything to given elements and take care of it yourself.


Why not use $('your_selector').clone(true).appendTo('another_selector').focus()?

0

精彩评论

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

关注公众号