Jquery背景图片轮换

这是一个使用Jquery类库,还有一外部jquery.backstretch.min.js类做成的背景图片不停的轮换.

前台调用代码:

<!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>
    <title>无标题页</title>
    <script type="text/javascript" src="JQuery/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="JQuery/jquery.backstretch.min.js"></script>
    <script type="text/javascript">
        //Create an array of images that you'd like to use
        var images=[
            "img/1.jpg",
            "img/2.jpg",
            "img/3.jpg",
            "img/4.jpg",
            "img/5.jpg"
        ];
        
        //A little script for preloading all of the images
        //It's not necessary,but generally a good idea
        $(images).each(function () {
            $('<img/>')[0].src = this;
        });
        
        //The index variable will keep track of which image is currently showing
        var index=0;
        
        //Call backstretch for the first time,
        //In this case,I'm settings speed of 500ms for a fadeIn effect between images.
        $.backstretch(images[index],{speed:800});
        
        //Set an interval that increments the index and sets the new image
        //Note:The fadeIn speed set above will be inherited
        setInterval(function(){
            index=(index>=images.length-1)?0:index+1;
            $.backstretch(images[index]);
        },3000);
    </script>
</head>
<body>
这是一个背景轮换的案例!
</body>
</html>


运行效果图:

 

轮换后的背景显示:

 

案例下载:http://download.csdn.net/detail/lovegonghui/9257165

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值