点击图片切换

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>图片切换</title>
        <style type="text/css">
            *{ padding: 0; margin: 0; list-style: none; }
            .all{ width: 650px; height: 250px; margin: 100px auto;position: relative;overflow: hidden;}
            .all ul{ position: relative; z-index: 1;}
            .all ul li{position: absolute; left: 0; top: 0;}
            .all ol{ position: absolute; z-index: 2; right: 10px; bottom: 10px;}
            .all ol li{ width: 20px; height: 20px; background: #333; border: 1px solid #ccc;
            font-weight: bold; text-align: center; line-height: 20px; float: left; margin-left: 10px;
            color: white; margin-top: 10px; cursor: pointer;}
            .all ol .current{ width: 30px; height: 30px; line-height: 30px; border: 1px solid #f60 ; color: #f60;
            margin-top: 0 ; }
        </style>
        <script type="text/javascript" src="练习/js/jquery-3.1.1.min.js"></script>
        <script type="text/javascript">
            $(function(){
                var num2=6;
                $("ol li").mouseover(function(){
                    $(this).attr("class","current");
                    $(this).siblings().attr("class","");
                    
                     
                    var num=$(this).index();
                    num2++;
                    $("ul li").eq(num).css("z-index",num2);
                    $("ul li").eq(num).css("left","650px");
                    $("ul li").eq(num).animate({ left:"0"},500);
                })
            
            })
        </script>
    </head>
    <body>
        <div class="all">
            <ul>
                <li><img src="01.jpg" width="650px" height="250px" /></li>
                <li><img src="02.jpg" width="650px" height="250px" /></li>
                <li><img src="03.jpg" width="650px" height="250px" /></li>
                <li><img src="04.jpg" width="650px" height="250px" /></li>
                <li><img src="05.jpg" width="650px" height="250px" /></li>
            </ul>
            <ol>
                <li>1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
                <li class="current">5</li>
            </ol>
        </div>
    </body>
</html>
posted @ 2016-11-08 20:58  tuobayi  阅读(111)  评论(0)    收藏  举报