我检查了很多次,但我不知道为什么 jQuery 不能工作。它在 jsfiddle 中有效!
html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Josue Espinosa</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="animate.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
</head>
<body>
<div id="menu">
</div>
</body>
</html>
CSS:
#menu{
width:15px;
height:200px;
background:red;
}
j查询:
$('#menu').hover(function(){
$("#menu").stop().animate({width : "300px"});
});
最佳答案
看来问题出在这里:
<script src="animate.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
你的 animate.js 在 jquery 加载之前运行
关于javascript - jQuery 在 jsfiddle 中有效,但在 html 文件中无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15101926/