Her fornylig lavede jeg et lignede eksempel, men lidt mere avanceret, hvor den henter billederne fra en bestemt mappe på din server, kræver dog PHP:
http://www.eksperten.dk/spm/924327#reply_7688274Men hvis vi skal holde os til det helt simple:
<html>
<head>
<SCRIPT type=text/javascript src="
http://code.jquery.com/jquery-latest.js"></SCRIPT><style type="text/css">
#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
}
#slideshow IMG.active {
z-index:10;
}
#slideshow IMG.last-active {
z-index:9;
}
</style>
<script type="text/javascript">
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 ); // Tids interval mellem billederne (5 sekunder)
});
</script>
</head>
<body>
<div id="slideshow">
<img src="img/img1.jpg" alt="" class="active" />
<img src="img/img2.jpg" alt="" />
<img src="img/img3.jpg" alt="" />
<!-- Du tilføjer alle dine billeder her -->
</div>
</body>
</html>