javascript - jQuery 在 jsfiddle 中有效,但在 html 文件中无效?

标签 javascript jquery html

我检查了很多次,但我不知道为什么 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/

相关文章:

javascript - 如何在 Kendo 模板中设置带有名称属性的 Treeview 复选框?

javascript - VueJs : How to pass a 'computed function' value from child component to the parent component using $emit(optionalPayload) and $on?

javascript - 滚动脚本被浏览器阻止

html - 使用 :after property 后无法为按钮设置动画

javascript - 背景图片CSS不显示

javascript - 将 D3.js 标签文本显示为两行

jquery - 循环遍历jquery中的元素集

javascript - 结合更改和 keyup

javascript - 将字符串与模板中的范围变量连接起来

javascript - Three.js 阴影 - 如何改进?