对不起标题... 所以我将 index.html 分成 div,然后我使用 contant 调用:
<script>$(function(){$("#work_bunch").load("wb.html"); });</script>
它工作正常,但我不会在 wb.html 中的元素上使用 jquery 我在索引中使用了它:
<script type="text/javascript" src="java_scripts/wb_op.js"></script>
我在 .js
文件中写的内容在索引中似乎工作正常
但我无法选择 wb.html
例如(如果 img5 是一个元素 wb.html):
$("#img5").mouseover(function(){
$(img5).fadeOut(2000);
});
最佳答案
你需要使用事件委托(delegate):
$(document).on('mouseover', '#element_in_wb_page', function() {
// your function
});
在你的情况下:
$(document).on('mouseover', '#img5', function() {
$(this).fadeOut(2000);
});
关于javascript - 如何在包含的 html 中使用 jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27352812/