【问题标题】:Push through list using jQuery使用 jQuery 推送列表
【发布时间】:2013-04-29 14:15:47
【问题描述】:

我有一个类似于li的每个函数

theList = $('#list li')
total = theList.length;   
  theList.each(function(i){      
   //stuff
    theItems = [];
    theItems.push($(this).animate({opacity:'1'},1111).delay(100).animate({opacity:'.8'}));
})

我正试图弄清楚如何隔离每个项目,执行动画,然后移动到下一个项目。

现在它只是一次完成所有这些。

奖励:如何防止它丢弃我的 CSS 悬停?

#list li:hover { opacity:1; }

【问题讨论】:

    标签: jquery list push each


    【解决方案1】:

    试试这个:

    var $theList = $('#list li');
    $theList.each(function (index) {
        $(this).animate({
            opacity: '1'
        }, 1111).delay(100 * index).animate({
            opacity: '.8'
        });
    });
    

    【讨论】:

    • delay(100 * index) 我从来没有想过这个。谢谢!
    • 无论如何要防止它丢弃我的css悬停效果? (也是不透明度)
    • 尝试删除每个循环中的一个动画,但一定要保持延迟。我不确定,删除哪个看起来会更好。所以,试一试……
    • 一旦 jQuery 动画发生,它仍然使它不再起作用。我想我必须添加一个 jQuery 悬停效果来保留 CSS 作为后备。
    猜你喜欢
    • 2020-02-20
    • 2015-05-14
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    相关资源
    最近更新 更多