jQuery的触发新加入HTML code [英] jQuery triggered newly added html code
问题描述
例我有2 HTML输入
Example I had 2 html input
<div class="wrap">
<input class="autocomplete" name="auto_1" />
<input class="autocomplete" name="auto_2" />
</div>
的 auto_1
和 auto_2
使用自动的jQuery UI完整,触发时文档准备 $(函数(){})
The auto_1
and auto_2
is using auto complete by jQuery UI and triggered when document ready $(function(){})
然后如果我们点击我的网站上的一个按钮,就会有另外一个按钮。按功能新增 $('包')追加('&LT;输入类=自动完成NAME =auto_3/&GT;')
And then if we click a button on my website, there will be another one button. Added by function $('.wrap').append('<input class="autocomplete" name="auto_3" />')
和现在大约会有3输入
<div class="wrap">
<input class="autocomplete" name="auto_1" />
<input class="autocomplete" name="auto_2" />
<input class="autocomplete" name="auto_3" />
</div>
但因为它是新增加的自动完成功能未在 auto_3
运行。
如何使它运行/自动完成使用?
How to make it running/use autocomplete?
推荐答案
我觉得这个问题是不是与点击新的输入,但对新的输入自动完成。当你添加新的元素
I think the problem is not with click on new input but with autocomplete on new input. When you add new element with
$('.wrap').append('<input class="autocomplete" name="auto_3" />')
您必须连接到自动完成这一新的领域,因此
You must attach autocomplete to this new field, so
$('input[name="auto_3"]').autocomplete();
或者使自动完成用的liveQuery插件: http://stackoverflow.com/a/4551313/657584
这篇关于jQuery的触发新加入HTML code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!