这是我的代码,我认为代码很好,没有错误,但仍然无法获取“div”标签的动画。任何帮助,将不胜感激。谢谢。
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("button").click(function() {
$("div").animate({
left: '450px'
});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>A simple animation example:</p>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
</body>
</html>
最佳答案
一般来说,如果资源通过 http
或 https
提供,您应该使用 src="//..."
,但是如果您使用 file:///
协议(protocol)在本地加载页面,//
将不起作用
替换
src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"
与
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"
关于javascript - jQuery 动画方法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42759637/