【发布时间】:2011-06-18 11:26:24
【问题描述】:
我正在运行这个:
$("*:not(#boo) .content").livequery(function(){
$("input, select").blah();
});
blah() 看起来像这样:
(function( $ ) {
$.fn.blah = function(){
var that = this;
return this.each(function(){
$(this).bind('change', function(){
// do some stuff here
return true;
}).change();
});
};
})(jQuery);
html 看起来像:
<div id="boo">
<div class="content">
<input type="text" />
<input type="text" />
...
</div>
</div>
<div class="content">
<input type="text" />
<input type="text" />
</div>
...
所以我要做的是将该函数和事件附加到不在#boo 内的每个输入元素。
这行得通,但问题是它像每秒一样一遍又一遍地这样做,并且浏览器冻结了。
我需要 livequery,因为 html 有时会更新,我需要再次将事件附加到新元素。
那么如何检查blah() 是否已经应用于输入元素并停在那里?
【问题讨论】: