Php jQuery自动完成不适用于动态表单字段
嘿,伙计们。。。我带着另一个问题回来了 我在表单字段上使用jquery自动完成。它起作用了 问题是,如果我在表单中动态添加另一行,它不会。是的,我一直将新字段的id切换为新字段 原件=示例1 动态添加=exampassed2、exampassed3等 我已经添加了它们的jQuery等价物Php jQuery自动完成不适用于动态表单字段,php,jquery,html,forms,autocomplete,Php,Jquery,Html,Forms,Autocomplete,嘿,伙计们。。。我带着另一个问题回来了 我在表单字段上使用jquery自动完成。它起作用了 问题是,如果我在表单中动态添加另一行,它不会。是的,我一直将新字段的id切换为新字段 原件=示例1 动态添加=exampassed2、exampassed3等 我已经添加了它们的jQuery等价物 $("#exampassed1").autocomplete({ source: "exams.php", minLength: 2 }); $("#exampassed2").autocom
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});
等等
我认为问题在于jQuery没有识别动态添加的元素,它只读取加载时出现的元素
有没有什么方法可以让jquery处理程序读取这些新添加的元素
我听说过bind和live函数,尽管我找不到实现这些函数的方法
非常感谢您在这里提供的任何小/全面帮助。。。干杯
我使用的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>
任何指点也非常感谢
再次感谢 不要打另一个电话。
$()。在接到前一个电话之前,请自动完成。如果您将它们像那样级联,javascript引擎将在您收到第一个用户的回调之前运行它们。因此,它找不到它要找的东西。不要给另一个$()打电话。在接到前一个的回电之前,请自动完成。如果您将它们像那样级联,javascript引擎将在您收到第一个用户的回调之前运行它们。因此它找不到它要找的东西。下面是我使用的代码。解决了
$().ready(function() {
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").live('focus', function() {
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});
});
});
干杯 下面是我使用的代码。解决了
$().ready(function() {
$("#exampassed1").autocomplete({
source: "exams.php",
minLength: 2
});
$("#exampassed2").live('focus', function() {
$("#exampassed2").autocomplete({
source: "exams.php",
minLength: 2
});
});
});
干杯 Hello Jason-谢谢你的提示-尽管如此-我该怎么做?Hello Jason-谢谢你的提示-尽管如此-我该怎么做?从最新版本的jQuery开始,我将使用.on()代替.live()来动态添加html元素。从最新版本的jQuery开始,我将使用.on()代替.live()用于动态添加的html元素。