Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  176] [ 7]  / answers: 1 / hits: 27259  / 14 Years ago, mon, january 31, 2011, 12:00:00

I have just one <img> element on my page. I change the src attribute of this image every 7 seconds.



I see the new images every 7 secs, but it would be nicer if I can add some fading or transitions effect when loading new image.



Does some have simple script for this?



I don't need any plugin. Just need some clue or few lines of sample for doing it.


More From » jquery

 Answers
118

Despite what KaiQing mentioned, you can use the callbacks ability of jQuery to fade in/out the image while you're changing it. This can be done like so: http://www.jsfiddle.net/bradchristie/HsKpq/1/



$('img').fadeOut('slow',function(){
$(this).attr('src','/path/to/new_image.png').fadeIn('slow');
});

[#93962] Sunday, January 30, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mireyag

Total Points: 73
Total Questions: 107
Total Answers: 85

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
mireyag questions
Sun, Aug 15, 21, 00:00, 3 Years ago
Wed, Dec 16, 20, 00:00, 3 Years ago
Tue, Sep 1, 20, 00:00, 4 Years ago
Sun, Jul 5, 20, 00:00, 4 Years ago
;