gpt4 book ai didi

javascript - jquery动态加载div问题

转载 作者:行者123 更新时间:2023-11-28 12:12:52 28 4
gpt4 key购买 nike

大家好,我是 HTML 和 Jquery 的新手。现在我可以使用加载功能从我的导航菜单中替换容器 div,但是如果从我想更改自身的容器中调用脚本,脚本将不起作用。例如我正在运行这个脚本

     $("#pagehome").click(function(){     $("#container").load("home.html #wraper", function ()     

when i call this from another div section(navigation menu) it works just fine and the divsection of container gets replaced with #wraper div of another page

 <div id=navigationmenu>
<a id="pagehome" href="#"><;img src"..."/></a>
</div>
</pre>

但是当我尝试从容器 div 调用脚本时它没有被执行

 <div id=container>
<a id="pagehome" href="#"><img src"..."/>
</div>

最佳答案

试试这个。

$(document).on('click', '#pagehome', function(){
...
return false;
});

关于javascript - jquery动态加载div问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19385464/

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