使用 jQuery 设置动画宽度

Animating width with jQuery

大家好,

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

快速提问。这是有效的,因为我用 jQuery 得到了它。但是我有很多 class 的跨度,如果我这样做是行不通的:

    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 无法使用本机 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);