码迷,mamicode.com
首页 > 其他好文 > 详细

鼠标滑过改变图片

时间:2016-06-16 18:22:36      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:function   replace   animate   图片   

jQuery中attr()函数不支持delay函数控制延迟,把attr函数加在animate的回调函数中

jQuery(function(){

        jQuery(‘.avia_image‘).hover(

        function() { 

urlss = jQuery(this).attr("src").replace("1.jpg","2.jpg");

            jQuery(this).stop().animate({opacity: ‘0.3‘},100, function(){jQuery(this).attr("src",urlss);});

jQuery(this).delay(101).animate({opacity: ‘1‘},100);

        }, 

        function() { 

        urltt = jQuery(this).attr("src").replace("2.jpg","1.jpg");

            jQuery(this).stop().animate({opacity: ‘0.3‘},100,function(){jQuery(this).attr("src",urltt);});

jQuery(this).delay(101).animate({opacity: ‘1‘},100);

        });

    }(jQuery));


鼠标滑过改变图片

标签:function   replace   animate   图片   

原文地址:http://luckyyang.blog.51cto.com/4524113/1789897

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!