动画一次jQuery后停止图像调整大小

时间:2015-11-21 05:35:12

标签: jquery

我正在使用窗口滚动功能,我希望在jQuery中动画一次后停止图像调整大小

    if(scroll >= 150){
        $('.abc').attr('src','one.jpg').animate({
            width: "5px",
            height: "5px"
        },
        function () { // fired the second time
            $(this).stop().animate({
                width: "50px",
                height: "50px",
            });
        });
}`

1 个答案:

答案 0 :(得分:0)

This code will stop image resize after animate once Jquery. Please check    it and let me know.

$(window).scroll(function(){
        var scroll = $(window).scrollTop();



        if(scroll >= 150){           
            $('.abc img').attr('src','http://demo-stable-ofbiz.apache.org/images/products/GZ-1000/small.png').animate
            ({
              width: "5px",
              height: "5px" 
            },
            /* You can use this image resize stop function this way. */
              function(){                                                                                       
               $(this).stop();
            }                               
        } 
});