Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Animate()在1.2之前的jQuery版本中不起作用_Javascript_Jquery_Jquery Animate - Fatal编程技术网

Javascript Animate()在1.2之前的jQuery版本中不起作用

Javascript Animate()在1.2之前的jQuery版本中不起作用,javascript,jquery,jquery-animate,Javascript,Jquery,Jquery Animate,当我使用1.2之前的jQuery版本时,“动画”会导致错误: 未捕获类型错误:未定义不是函数 从我阅读的文档来看,它应该在早期版本中使用样式和持续时间参数,所以我觉得我一定做错了什么 例如,以下代码可以正确运行: <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-1.2.js"></script> <script language="

当我使用1.2之前的jQuery版本时,“动画”会导致错误:

未捕获类型错误:未定义不是函数

从我阅读的文档来看,它应该在早期版本中使用样式和持续时间参数,所以我觉得我一定做错了什么

例如,以下代码可以正确运行:

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.2.js"></script>
<script language="Javascript" type="text/javascript">

function dotheStuff(){
    var div = document.createElement('div');
    div.style.width = '20px';
    div.style.height = '20px';
    div.style.backgroundColor = 'black';
    document.body.appendChild(div);

    $(div).animate({marginLeft:'600px'}, 2000);
}

</script>
</head>
<body onload="dotheStuff()">
</body>
</html>
当此代码产生错误时:

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.1.4.js"></script>
<script language="Javascript" type="text/javascript">

function dotheStuff(){
    var div = document.createElement('div');
    div.style.width = '20px';
    div.style.height = '20px';
    div.style.backgroundColor = 'black';
    document.body.appendChild(div);

    $(div).animate({marginLeft:'600px'}, 2000);
}

</script>
</head>
<body onload="dotheStuff()">
</body>
</html>
唯一的区别是jQuery的版本


多谢各位

我将其称为一个bug,您可以通过删除单位并将您的值设为数字来解决它:


$div.animate{marginLeft:600},2000年

请看这个。有些动画功能在XHey版本之前不起作用,我确实读过,但从我看到的情况来看,属性和持续时间值从1.0开始就可用了。我始终看到添加的特定版本,但在1.2之前的版本中,没有任何东西会阻止动画使用这些参数。有什么我遗漏的吗?非常感谢。但你为什么在乎?1.2是很久以前发布的,现在假设它是一个七年前修复的bug。这些有什么关联?您的目标受众是否在2006年陷入困境?哪些浏览器给出了错误信息?您使用什么方法测试旧浏览器?模拟,浏览器模式?