网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 简单的jQuery banner图片轮播实例代码
范文
    这篇文章主要介绍了简单的jQuery banner图片轮播实例代码的相关资料,需要的朋友可以参考下
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>无标题页</title>
    <script src="js/jquery-2.1.4.js" type="text/javascript"></script>
    <style type="text/css">
    .clear{overflow:hidden; clear:both; width:0px; height:0px; }
    .imgbox{width:640px; margin:0 auto; text-align:center; }
    ul{padding:0px; margin:0px;}
    ul li{float:left; list-style:none; }
    ul li.select{display:block;}
    .imgnum span{border-radius:10px; font:normal normal bold 12px/15px 微软雅黑; color:#FFF; margin-left:5px; padding:3px 6px 3px 6px; background-color:#F90; cursor:pointer;}
    .imgnum span.onselect{background-color:#F00;}
    .imgnum{text-align:center; float:right; margin:-30px 30px; position:relative;}
    </style>
    </head>
    <body>
    <div>
    <ul id="banner_img">
    <li><img src="images/banner1.jpg"/></li>
    <li><img src="images/banner2.jpg"/></li>
    <li><img src="images/banner3.jpg"/></li>
    <li><img src="images/banner4.jpg"/></li>
    <li><img src="images/banner5.jpg"/></li>
    </ul>
    <div></div>
    <div>
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>5</span>
    </div>
    </div>
    <script type="text/javascript">
    var time = "";
    var index = 1;
    $(function () {
    showimg(index);
    //鼠标移入移出
    $(".imgnum span").hover(function () {
    clearTimeout(time);
    var icon=$(this).text();
    $(".imgnum span").removeClass("onselect").eq(icon-1).addClass("onselect");
    $("#banner_img li").hide().stop(true,true).eq(icon-1).fadeIn("slow");
    }, function () {
    index=$(this).text()> 4 ? 1 :parseInt($(this).text())+1;
    time = setTimeout("showimg(" + index + ")", 3000);
    });
    });
    function showimg(num) {
    index = num;
    $(".imgnum span").removeClass("onselect").eq(index-1).addClass("onselect");
    $("#banner_img li").hide().stop(true,true).eq(index-1).fadeIn("slow");
    index = index + 1 > 5 ? 1 : index + 1;
    time = setTimeout("showimg(" + index + ")", 3000);
    }
    </script>
    </body>
    </html>
    注意要引用 Jquery 文件,图片我就不放上来了,自己替换掉,注意图片长宽。
    以上所述是小编给大家分享的简单的jQuery banner图片轮播实例代码,希望对大家有所帮助!
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/23 21:47:44