HTML:
div#exmkp p:nth-of-type(1) {
margin-top : 10px;
}
我确实会在html中使用同一类输入中的类添加更多输入到html JS:1:
<input class="typeahead" id="jj" type="text">
<a href='#' id="a">add input</a>
这是为类做自动完成 JS:2:
$("#a").each(function() {
$(this).on("click", function(){
$('#jj).append('<input class="typeahead" type="text"');
});});
我如何使用class&#34; typeahead&#34;?
答案 0 :(得分:1)
自动填充功能不支持事件委派。您需要将自动完成功能附加到新添加的元素。
append将在最后位置添加元素。您可以使用:last
.ggg
的集合中的#kkkk
选择器来定位它
$('button').click(function(){
$('#kkkk').append("<input type='text' class='ggg'/>");
$('#kkkk .ggg:last').autocomplete({
//BIND SOURCE HERE
});
});
答案 1 :(得分:0)
var mmm;
$.post('diagnoses.php',{},function(data){
mmm = data;
},"json")
.done(function() {
$('.ui-widget .auto').autocomplete({
source: mmm
});
});
$('#a').each(function(){
$(this).click(function(){
$('<input class="auto" type="text" placeholder="שם אבחנה">').appendTo('.ui-widget');
$('.ui-widget .auto').autocomplete({
source: mmm
});
});
});