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

选项卡切换

时间:2016-12-14 01:57:26      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:type   .class   会议   htm   script   title   back   .sh   classname   

1.

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .red{background: red}
        #list{list-style: none;}
        #list li{position: relative; float: left; margin: 50px;}
        div, .hide{display: none}
        .show{display: block}

    </style>
</head>
<body>
<script>
    window.onload = function(){
        var oUl = document.getElementById(‘list‘);
        var arrLi = oUl.getElementsByTagName(‘li‘);

        for(var i = 0; i < arrLi.length; i++){
            fnTab(arrLi[i], arrLi);
        }

        function fnTab(oLi, aLi){
            var oA = oLi.getElementsByTagName(‘a‘)[0];
            var oDiv = oLi.getElementsByTagName(‘div‘)[0];
            oA.onclick = function () {
                for(var i = 0; i < aLi.length; i++){
                    aLi[i].getElementsByTagName(‘a‘)[0].className = ‘‘;
                    aLi[i].getElementsByTagName(‘div‘)[0].className = ‘hide‘;
                }
                oA.className = ‘red‘;
                oDiv.className = ‘show‘;
            }
        }

    }
</script>
<ul id="list">
    <li>
        <a  href="javascript:;">简介</a>
        <div>简介.........</div>
    </li>
    <li>
        <a href="javascript:;">会议</a>
        <div>会议.........</div>
    </li>
    <li>
        <a href="javascript:;">回看</a>
        <div>回看.........</div>
    </li>
</ul>

</body>
</html>

  

选项卡切换

标签:type   .class   会议   htm   script   title   back   .sh   classname   

原文地址:http://www.cnblogs.com/bravolove/p/6175690.html

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