Navigation

Search

Categories

On this page

Using jQuery to Create an Image Slideshow

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 245
This Year: 51
This Month: 0
This Week: 0
Comments: 0

Sign In
Pick a theme:

# Thursday, June 03, 2010
Thursday, June 03, 2010 7:22:31 PM (GMT Daylight Time, UTC+01:00) ( jQuery )


Here is a working demo of this code.

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Image Slideshow</title>

<script src="http://code.jquery.com/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
    var imgs = [
    '../images/1.jpg',
    '../images/2.jpg',
    '../images/3.jpg',
    '../images/4.jpg'];
    var cnt = imgs.length;
    var $imageSlide = $('img[id$=imageSlide]');
    // set the image control to the last image
    $imageSlide.attr('src', imgs[cnt - 1]);
    setInterval(Slider, 4000);
    function Slider() {
        $imageSlide.fadeOut("slow", function () {
        $(this).attr('src', imgs[(imgs.length++) % cnt]).fadeIn("slow");
     });
    }
});
</script>

</head>


<body>
<form runat="server" id="form1">

<div class="smallDiv">
<h2>Image Slide Show - Image Changes Every 4 Seconds</h2><br />
<asp:Image ID="imageSlide" runat="server" class="imgdiv" />
</div>

</form>

</body>
</html>