Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In a image i want to change the images one by one as, new image fadein and old image fadeout. Please help me if you know. Thank you.
Posted
Updated 17-Feb-12 0:15am
v2

1 solution

Try jQuery,

You can query for objects in your page, for example $("img.first") matches all images with a class 'first'.

So if you have two images on your page :
<img src="/images/first.jpg" class="first" alt="First" />
<img src="/images/second.jpg" class="second" alt="Second" style="display: none;" />


Then use the following javascript to fade out the first, and fade in the second image. Notice I wrote this code to be executed as soon as the page is loaded :

JavaScript
$(document).ready(function ()) {
    $("img.first").fadeOut();
    $("img.second").fadeIn();
}


See the http://jquery.com/[^] website for more information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900