gpt4 book ai didi

javascript - 如何使用 .load() 加载脚本

转载 作者:行者123 更新时间:2023-12-01 02:32:06 24 4
gpt4 key购买 nike

Possible Duplicate:
Why does jQuery or a DOM method such as `getElementByID` not find the element?

我使用 jquery.load() 加载文件。在我的 load_to.html 中,我将 id 的元素定位为

$('#users').change(function() {
alert('hello');
});

此元素存在于 load_from.html 中。我无法瞄准这个目标。但是当我检查页面时,我可以看到这个元素。

我像这样加载了页面

$('#mydiv').load('/user/1/edit form');

如何定位元素?

最佳答案

在其委托(delegate)签名中使用on:

$('#mydiv').on('change', '#users', function() {
alert('hello');
});

Read the docs

关于javascript - 如何使用 .load() 加载脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14124984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com