开发者

HOw to use fadeIn and FadeOut in Jquery image change

开发者 https://www.devze.com 2022-12-29 04:44 出处:网络
I am chnaging the image src onClick event like below IF the hyperlink is clicked then i need to change the image in a div box

I am chnaging the image src onClick event like below

IF the hyperlink is clicked then i need to change the image in a div box

<div id="left_img">
     <img开发者_开发知识库 style="float: right;" src="/image/char.gif">
                    </div>

Jquery

$("#left_img img").attr("src","http://www.abc.net/image/2_char.gif");

Now i want that instead of abrupt change of image there should fade out of old image and fadein of new image

How can i do that


$("#left_img img").fadeOut(500, function() {

    $(this).attr("src","http://www.abc.net/image/2_char.gif").fadeIn(500);

});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号