所以我创建了一个简单的 html 页面:
index.html 文件:
<html>
<head>
</head>
<body>
<div class="menu">
hello
</div>
<div class="test">
Menu
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="app.js"></script>
</body>
</html>
这是 app.js 文件:
var main = function() {
$('.test').click(function(){
$('body').animate({
left: '500px'
},200);
})
}
$(document).ready(main)
我试图了解我做错了什么,看起来它应该有效..
还尝试下载 jquery-2.1.1.min.js
并使用它,但仍然在单击菜单时,文本没有移动..
最佳答案
您需要将 position
css 属性设置为 body
才能工作 left
。
body{
position:relative;
}
关于javascript - 简单的 JQuery 脚本动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26249958/