我非常不明白为什么这个基本的 JQuery 代码不起作用,我只想在单击按钮时将此文本向右移动 500px。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src = "jquery-2.0.1.js"></script>
<script>
$(document).ready(function(){
$('button').click(function(){
$('div').animate({right:'500px'}, fast);
});
});
</script>
</head>
<body>
<div style = "position: absolute; top: 100px;">
Test Box
</div>
<button>click me</button>
</body>
</html>
最佳答案
在部分中:$('div').animate({right:'500px'}, fast);
fast 必须是:"fast"
它对我有用!
关于javascript - JQuery 动画不起作用。可能语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16919885/