Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.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 使用jQuery设置宽度动画_Javascript_Jquery_Html_Jquery Animate - Fatal编程技术网

Javascript 使用jQuery设置宽度动画

Javascript 使用jQuery设置宽度动画,javascript,jquery,html,jquery-animate,Javascript,Jquery,Html,Jquery Animate,各位好, $(".textF").animate({width: actualWidth + "px"}, durations[0]*1000); 快速提问。这很有效,因为我用jQuery获得了它。但我在这个类中有很多跨度,如果我这样做,就不起作用了: var fElements=document.getElementsByClassName("textF"); fElements[0].animate({width: actualWidth + "px"}, dura

各位好,

    $(".textF").animate({width: actualWidth + "px"}, durations[0]*1000);
快速提问。这很有效,因为我用jQuery获得了它。但我在这个类中有很多跨度,如果我这样做,就不起作用了:

    var fElements=document.getElementsByClassName("textF");
    fElements[0].animate({width: actualWidth + "px"}, durations[0]*1000);
我得到的错误是:

未捕获的DomeException:未能对“元素”执行“动画”:不支持部分关键帧


jquery
不使用本机
javaScript
函数

错误?
animate()
由jquery定义,而不是使用本机
Javascript

请参阅jquery文档

$(fElements[0]).animate({width: actualWidth + "px"}, durations[0]*1000);


jquery
不使用本机
javaScript
函数

错误?
animate()
由jquery定义,而不是使用本机
Javascript

请参阅jquery文档

$(fElements[0]).animate({width: actualWidth + "px"}, durations[0]*1000);



您在页面中包含了
jQuery
,为什么要使用
pure JS
?这是什么意思?我的意思是您包含了
jQuery
,那么为什么您厌倦了使用
getElementsByClassName
而不是
$('…')
?因为它没有创建我的“var fElements”作为数组。使用getElementsByClassName,你没有理解我,兄弟,但没关系;)您在页面中包含了
jQuery
,为什么要使用
pure JS
?这是什么意思?我的意思是您包含了
jQuery
,那么为什么您厌倦了使用
getElementsByClassName
而不是
$('…')
?因为它没有创建我的“var fElements”作为数组。使用getElementsByClassName,你没有理解我,兄弟,但没关系;)无需在
animate
功能中使用
px
。默认单位为像素。谢谢!我真的很感激。但是有什么区别?我真的不明白。我知道这是关于DOM元素的,但是…@davidradellcasellas,因为jquery声明不同于原生js声明。最好看看这个线程,了解更多关于这方面的信息,谢谢much@DavidPradellCasellas始终欢迎..继续学习..快乐编码..:-)无需在
animate
功能中使用
px
。默认单位为像素。谢谢!我真的很感激。但是有什么区别?我真的不明白。我知道这是关于DOM元素的,但是…@davidradellcasellas,因为jquery声明不同于原生js声明。最好看看这个线程,了解更多关于这方面的信息,谢谢much@DavidPradellCasellas始终欢迎..继续学习..快乐编码..-)