【问题标题】:jquery typeWatch with Dynamic input fields added on the fly动态添加动态输入字段的 jquery typeWatch
【发布时间】:2010-03-15 00:39:48
【问题描述】:

如何获取动态添加的输入字段的 ID? 我的脚本在单击按钮时添加输入字段,使用

var ix = 1;
$(template2(ix++)).appendTo("#dataTable tbody");
var template2 = jQuery.format($("#template2").val()); 

我还在插入新字段之后添加了这一行,因此它将 typeWatch 添加到所有 .email 类字段中。

$(".email").typeWatch( { highlight:true, callback:function(){alert("changed search text"); },  wait:750  } );

现在,在回调函数中,我想获取输入字段的Id typeWatch 回调被触发。

请指教。

谢谢

【问题讨论】:

    标签: jquery dynamic typewatch


    【解决方案1】:

    在回调函数中,this.el 包含触发回调的元素的 DOM 对象。所以,

    $(this.el).attr('id')
    

    应该为您提供您正在寻找的 id。这是插件的2.0.0版本下

    【讨论】:

      猜你喜欢
      • 2021-05-21
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-05
      • 1970-01-01
      相关资源
      最近更新 更多