如何同时链接运行两个Jquery动画?

问题描述 投票:0回答:1

我想让一个物体来回移动,同时物体同时改变它的不透明度。

我尝试使用队列和回调函数来完成这项工作。

$(document).ready(function(){
  $(".button").click(function(){
   $("#divv").animate({left:'+=500'},"slow","linear")
     .animate({left:'-=500'},"slow","linear")
     .animate({left:'-=500'},"slow","linear")
    .animate({left:'+=500'},"slow","linear")

$("#divv").animate({opacity:'-=0.8'},"slow","linear")
   .animate({opacity:'+=0.8'},"slow","linear")
   .animate({opacity:'-=0.8'},"slow","linear")
   .animate({opacity:'+=0.8'},"slow","linear")

}) });

对象左右移动,然后更改不透明度。

jquery jquery-animate
1个回答
0
投票

您可以一次为多个属性设置动画,如下所示:

$(document).ready(function(){
    $(".button").click(function(){
        $("#divv").animate({left:'+500', opacity:'-=0.8'}, "slow", "linear");
    });
});

希望这个有效!

© www.soinside.com 2019 - 2024. All rights reserved.