Thorsday

Thorsday Research Project

Webcommgard: Subduing Loki's Web Mischief


jQuery slideshow

The slide show can be placed anywhere. Works best inside its own div.

Displays first image when Javascript is disabled

Files Needed

Inline Code

In the head:

<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()", 3000 );
});

</script>

		

Some 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;
}
		

In the body:

<div id="slideshow">
	<img src="images/jack1.jpg" alt="" class="active" />
	<img src="images/jack2.jpg" alt="" />
	<img src="images/jack3.jpg" alt="" />
	<img src="images/jack4.jpg" alt="" />
</div>

		

Special Considerations

Implementation

http://www.isu.edu/urelate/photo_services/index.shtml

Source

http://jonraasch.com/blog/a-simple-jquery-slideshow