zoukankan      html  css  js  c++  java
  • 原始tab栏切换

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .box{
                height: 300px;
                width: 400px;
                border:1px solid #000;
                margin: 100px auto;
            }
            .mt span{
                display: inline-block;
                width: 93px;
                height: 50px;
                border: 1px solid #333;
                text-align: center;
                line-height: 50px;
                background: #ff3;
            }
            .mt span.current{
                background: purple;
            }
            ul li{
                list-style: none;
                float: left;
                width: 400px;
                height: 250px;
                border: 1px solid #e0e0e0;
                display: none;
                background: purple;
            }
            ul li.show{
                display: block;
            }
        </style>
    </head>
    <body>
        <div class="box">
            <div class="mt">
                <span class="current">新闻</span>
                <span>体育</span>
                <span>娱乐</span>
                <span>八卦</span>
            </div>
            <div class="mb">
                <ul>
                    <li class="show">新闻模块</li>
                    <li>体育模块</li>
                    <li>娱乐模块</li>
                    <li>八卦模块</li>
                </ul>
            </div>
        </div>
    </body>
    </html>
    <script>
        window.onload=function () {
            var spans=document.getElementsByTagName('span');
            var lis=document.getElementsByTagName('li');
            for(var i=0;i<spans.length;i++){
                // 得到span的索引
                spans[i].index=i;
                spans[i].onmouseover=function () {
                    for(var j=0;j<spans.length;j++){
                        spans[j].className=' ';
                        lis[j].className=' ';
                    }
                    this.className='current';
                    lis[this.index].className='show';
                }
            }
        }
    </script>
  • 相关阅读:
    Android-内存泄漏
    性能adb命令
    设置Nginx开机自启动
    【转 记录】python中的encode以及decode
    SVN 提交回滚
    Linux基础
    CentOS6.X关闭防火墙
    SCP用法
    Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置(转)
    (转,记录用)jQuery页面加载初始化的3种方法
  • 原文地址:https://www.cnblogs.com/yangguoe/p/8138031.html
Copyright © 2011-2022 走看看