The easiest way is to use jQuery:
<img src="..." id="myImage">
<script type="text/javascript">
jQuery(function(){
$("#myImage").fadeIn();
$("#myImage").fadeOut();
});
</script>
Documentation:
http://api.jquery.com/fadeIn/
You can also change the attenuation time by passing a parameter
$("#myImage").fadeOut("slow");
$("#myImage").fadeOut("fast");
$("#myImage").fadeOut(1500);
Update loop creation:
function fadeIn()
{
$(this).fadeIn( fadeOut );
}
function fadeOut()
{
$(this).fadeOut( fadeIn );
}
fadeIn.call($("#myImage"));
source
share