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始终欢迎..继续学习..快乐编码..-)