<分区>
当我输入代码时,我用标题标记一个 div,然后放入 jQuery 代码,这样当我将鼠标悬停在它上面时它就会展开。但是,当我将它放入我的代码中时,它似乎不起作用?
我使用的代码在这里:
最佳答案
看起来您没有链接到 jQuery 库。尝试将以下行之一添加到您的 <head>
:
1.x
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
2.x
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
例如
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="script.js"></script>
<title> Risebush|home </title>
</head>
更新:
将您的 script.js 替换为:
$(document).ready(function () {
$("#info").hover(function () {
$(this).closest("#info").css("z-index", 1);
$(this).animate({
height: "400"
}, "fast");
}, function () {
$(this).closest("#info").css("z-index", 0);
$(this).animate({
height: "250"
}, "fast");
});
});
关于jQuery 根本不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29551474/