我想在每一行上自动完成,但它只适用于第一行。
自动完成在第一行工作正常,但是当我添加新行时,自动完成不起作用。我的代码在这里请任何解决方案
这是HTML:
<table id="items">
<thead>
<th>Items</th>
</thead>
<tbody>
<tr>
<td><input class="input3 item" name="name_1" type="text" value="" autocomplete="off"></td>
</tr>
</tbody>
</table>
<br clear="both">
<div id="addmore">Add new line</div>
这是jQuery:
// add new line
$("#addmore").click(
function () {
var someText = '<td><input class="input3 item" name="name_2" type="text" value=""></td>';
var newDiv = $("<tr>").append(someText);
$('#items').append(newDiv);
}
);
// get autocomplete tags
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( ".item" ).autocomplete({
source: availableTags,
minLength: 1,
});
您可以在 Js Fiddle 中看到:http://jsfiddle.net/anosim/n3auc/4/
请帮助我,在此先感谢