jQuery fades out one picture to another, for example, the following html:
First, make sure the size of the div is the same as the image size. This div has another background image, as follows:
css code:
.fade
{
background-image:url('images/2.jpg');
width:300px;
height:225px;
}
jQuery code is as follows:
$(document).ready(function () {
$(".fade").hover(function ( ) {
$(this).find("img").stop(true, true).animate({ opacity: 0 }, 500);
}, function () {
$(this ).find("img").stop(true, true).animate({ opacity: 1 }, 500);
});
});
Complete implementation code:
< ;script type="text/javascript">
$(document).ready(function () {
$(".fade").hover(function () {
$(this). find("img").stop(true, true).animate({ opacity: 0 }, 500);
}, function () {
$(this).find("img").stop (true, true).animate({ opacity: 1 }, 500);
});
});
Author : jQuery Learning