tabCase

作者: Jadon7 | 来源:发表于2018-10-06 22:41 被阅读0次
    <!DOCTYPE html>
    <html>
    <head>
        <title>tabCase</title>
    </head>
    <script type="text/javascript">
        window.onload=function()
        {
            var oDiv=document.getElementById('div1');
            var aBtn=oDiv.getElementsByTagName('input');
            var aDiv=oDiv.getElementsByTagName('div');
    
            for (var i = 0; i < aBtn.length; i++) 
            {
                aBtn[i].index=i;
                aBtn[i].onmouseover=function()
                {
                    for (var j = 0; j < aBtn.length; j++) 
                    {
                        aDiv[j].style.display='none';
                        aBtn[j].className='';
                    }
                    this.className='hve';
                    aDiv[this.index].style.display='block';
                };
            }
        };
    </script>
    <style type="text/css">
        .content{
            width: 300px;
            height: 300px;
            background: #eee;
            display: none;
        }
        .hve{
            border: none;
            background-color: #eee;
        }
    </style>
    <body>
        <div id="div1">
            <input type="button" value="tab1" class="hve">
            <input type="button" value="tab2">
            <input type="button" value="tab3">
            <input type="button" value="tab4">
            <div class="content" style="display:block">1111</div>
            <div class="content">2222</div>
            <div class="content">3333</div>
            <div class="content">4444</div>
        </div>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:tabCase

          本文链接:https://www.haomeiwen.com/subject/lrrkaftx.html