javascript - JQuery 动画不起作用。可能语法不正确

标签 javascript jquery html

我非常不明白为什么这个基本的 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/

相关文章:

android - CSS3 KeyFrame Translate Animation - Android 严重跳帧

javascript - 如何触发选择元素的点击事件? (不变)

javascript - 获取选择选项的值,然后用它来搜索/过滤

javascript - 查询 - 将 <br/> 从文本区域传递到隐藏的 div 以自动调整大小

javascript - DeviantArt 如何在他们的图像中实现阴影?

php - 如何根据条件在 php while 循环中填充两个不同的 html 表?

javascript - 我可以使用 ajax 在 2 个 Android 设备之间发送和检索数据吗?

javascript - 我在哪里使用 asp 母版页放置 javascript?

jQuery 动画在服务器端的 Chrome 中速度较慢且滞后

javascript - 页面加载后 Bootstrap 总是改变元素在手机上的绝对位置