通过 jquery 从其他文件加载的链接不起作用
我打开了一个看起来完全像这样的链接: http://localhost/anysite/#data_aa
然后,jquery 执行以下内容:
$('a[href^="data_"]').click(function(){
//code to be executed and at end,
$("anyDIV").load('anyfile.php?parameter=anyvalue');
});
这将选择 href
属性以“data_”开头的所有链接,以从 PHP 文件加载数据。
数据和链接已成功加载,但加载的链接不起作用,这看起来与我在开头提到的完全相同 http://localhost/anysite/#data_ss
...
希望,您理解我的问题并且能够帮助我......
I opened a link which looks exactly like this: http://localhost/anysite/#data_aa
Then, jquery performs the following:
$('a[href^="data_"]').click(function(){
//code to be executed and at end,
$("anyDIV").load('anyfile.php?parameter=anyvalue');
});
This selects all the links where the href
attribute starts with "data_" to load data from PHP file.
Data and links are loaded successfully but the loaded links do not work which exactly looks as same I mentioned in beginning like this http://localhost/anysite/#data_ss
...
Hope, You understood my problem and will be able to help me......
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
live
方法。click
绑定发生在页面加载时,因此之后动态添加的任何内容都不会包含在该绑定中,live
方法有助于实现这一点。You need to use the
live
method.The
click
bind happens at page load, so any content dynamically added afterwards wont be included in that bind, thelive
method facilitates this.