码迷,mamicode.com
首页 > 其他好文 > 详细

图片轮播

时间:2016-04-26 10:52:57      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>图片轮播</title>
        <meta name="viewport" content="initial-scale=1, maximum-scale=1">
        <!--需要引入jquery-->
    </head>
    <body>
        <div id="scrollimg">
            <img src="">
            <img src="">
            <img src="">
        </div>
        <script>            
            $(function() {
                var numpic = $(#scrollimg img).size() - 1;
                var nownow = 0;
                var inout = 0;
                var TT = 0;
                var SPEED = 5000;
                var imgclomns = $(#scrollimg).find(img);
                var imgtxt = $(#imgtxt).find(div.pic_info);
            
                function Scroll() {
                    var LL = nownow - 1;
                    if (numpic >= 1) {
                        if (nownow < numpic) {
                            imgclomns.eq(LL).fadeOut();
                            imgtxt.eq(LL).hide();
                            imgclomns.eq(nownow).fadeIn(500);
                            imgtxt.eq(nownow).fadeIn(1000);
                            nownow++;
                        } else {
                            imgclomns.eq(LL).fadeOut();
                            imgtxt.eq(LL).hide();
                            imgclomns.eq(nownow).fadeIn(500);
                            imgtxt.eq(nownow).fadeIn(1000);
                            nownow = 0;
                        }
                    } else {
                        imgclomns.eq(0).fadeIn(500);
                        imgtxt.eq(0).fadeIn(1000);
                        window.clearInterval(TT);
                    }
                }
                Scroll();
                TT = setInterval(Scroll, SPEED);
            })  
        </script>
    </body>
</html>

 

图片轮播

标签:

原文地址:http://www.cnblogs.com/wteng/p/5395476.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!