嘿,伙计们...我带着另一个问题回来了。
我在一个表单域上使用jquery自动完成。它起作用了!
问题是,然后我动态地向表单添加另一行,它不会。是的,我不断地将新字段的id切换为新的id。
原始=动态添加的exampassed1 = exampassed2、exampassed3等...
我已经添加了它们的jQuery等效项
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});以此类推。
我认为问题在于jQuery无法识别动态添加的元素,它只读取加载时出现的元素……
有没有办法让jquery处理程序读取这些新添加的元素?
我听说过绑定和活动函数,尽管我找不到实现这些函数的方法……
这里的任何一点/完整的帮助都是非常感谢的。干杯!
我使用的jQuery
$().ready(function() {
$("#autonco").autocomplete({
source: "nco.php",
minLength: 2
});
$("#autonco1").autocomplete({
source: "nco.php",
minLength: 2
});
$("#autonco2").autocomplete({
source: "nco.php",
minLength: 2
});
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});
});已经存在的代码...
<td align="center" valign="top">
<input type="text" id="exampassed1" name="exam[]" />
</td>动态添加的代码...
<td valign="top" align="center">
<input id="exampassed2" name="exam[]" type="text">
</td>任何指针也是值得感谢的!
再次感谢!
发布于 2010-10-31 14:09:32
下面是我使用的代码。解决了!
$().ready(function() {
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").live('focus', function() {
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});
});
});干杯!
发布于 2010-10-30 02:04:28
在收到前一个$().autocomplete的回调之前,不要调用另一个a。如果你把它们级联在一起,javascript引擎会在你得到第一个回调函数之前运行所有的函数。因此,它找不到它正在寻找的东西。
https://stackoverflow.com/questions/4053529
复制相似问题