查询动画函数调用

Query Animation Function Call

本文关键字:函数调用 动画 查询      更新时间:2023-09-26

我有一个包含多个框的网站,我想为动画创建一个函数,这样我就不必将它们添加到每个悬停框中,因为有些包含不同的动画。

由于某种原因,我无法调用框中的动画,如果我复制函数代码并将其放置在框中,它可以正常工作,但可以从函数调用它来让它工作。

function aniIn() {
    $(".br-t", this).stop().animate({ "width": "100%" }, 500, "easeOutQuint" ),
}
function aniOut() {
    $(".br-t", this).stop().animate({ "width": "0"}, 900, "easeOutQuint" ),
}
$("a#box01").hover(function() {
        $("#background").fadeIn(500);
        aniIn();
    }, function() {
        $("#background").stop().fadeOut(900);
        aniOut()
});

.HTML:

<a href="#" id="box01" title="box"></a>

任何帮助都会很棒。

TJ.

尝试以下代码:

function aniIn(current) {  
 $(".br-t", current).stop().animate({ "width": "100%" }, 500, "easeOutQuint" ),
}
function aniOut(current) {
    $(".br-t", current).stop().animate({ "width": "0"}, 900, "easeOutQuint" ),
}
$("a#box01").hover(function() {
        $("#background").fadeIn(500);
        aniIn(this);
    }, function() {
        $("#background").stop().fadeOut(900);
        aniOut(this);
});