gpt4 book ai didi

javascript - 使用 jQuery 动画宽度

转载 作者:行者123 更新时间:2023-11-28 14:53:13 33 4
gpt4 key购买 nike

大家好,

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

快速提问。这是可行的,因为我是用 jQuery 得到的。但我对该类有很多跨度,如果我这样做是行不通的:

    var fElements=document.getElementsByClassName("textF");
fElements[0].animate({width: actualWidth + "px"}, durations[0]*1000);

我得到的错误:

Uncaught DOMException: Failed to execute 'animate' on 'Element': Partial keyframes are not supported.

最佳答案

jquery 无法使用 native javaScript 函数。

错误?-animate() 由 jquery 定义,而不是使用原生 Javascript

请参阅animate() jquery 文档

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

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

关于javascript - 使用 jQuery 动画宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43806080/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com