美文网首页
jQuery animate

jQuery animate

作者: 潇潇翔子 | 来源:发表于2018-08-24 17:33 被阅读9次

    jQuery 动画 - animate() 方法

    $(selector).animate({params},speed,callback);
    

    必需的 params 参数定义形成动画的 CSS 属性。
    可选的 speed 参数规定效果的时长。它可以取以下值:"slow"、"fast" 或毫秒。
    可选的 callback 参数是动画完成后所执行的函数名称。

    jQuery animate() - 操作多个属性

    $("button").click(function(){
      $("div").animate({
        left:'250px',
        opacity:'0.5',
        height:'150px',
        width:'150px'
      });
    }); 
    

    jQuery animate() - 使用相对值

    $("button").click(function(){
      $("div").animate({
        left:'250px',
        height:'+=150px',
        width:'+=150px'
      });
    });
    

    jQuery animate() - 使用队列功能

    $("button").click(function(){
      var div=$("div");
      div.animate({height:'300px',opacity:'0.4'},"slow");
      div.animate({width:'300px',opacity:'0.8'},"slow");
      div.animate({height:'100px',opacity:'0.4'},"slow");
      div.animate({width:'100px',opacity:'0.8'},"slow");
    });
    

    相关文章

      网友评论

          本文标题:jQuery animate

          本文链接:https://www.haomeiwen.com/subject/ouriiftx.html