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

Example017简单的下拉框

时间:2016-04-11 23:51:58      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>简单的下拉框</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        .main {
            width: 1200px;
            height: 300px;
            margin: 0 auto;
        }
        h3 {
            margin-left: 20px;
            background-color: #888;
        }
        .dis {
            float: left;
        }
        li {
            list-style: none;
            margin-left: 30px;
            margin-top: 10px;
        }
        ul {
            display: none;
            margin-left: 19px;
            background-color: #888;
        }
    </style>
</head>
<body>
    <div class="main">
        <div class="dis">
            <h3 onmouseover="one(0)">z选项一</h3>
            <ul>
                <li>111</li>
                <li>222</li>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
        <div class="dis">
            <h3 onmouseover="one(1)">z选项二</h3>
            <ul>
                <li>111</li>
                <li>222</li>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
        <div class="dis">
            <h3 onmouseover="one(2)">z选项三</h3>
            <ul>
                <li>111</li>
                <li>222</li>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
        <div class="dis">
            <h3 onmouseover="one(3)">z选项四</h3>
            <ul>
                <li>111</li>
                <li>222</li>
                <li>333</li>
                <li>444</li>
            </ul>
        </div>
    </div>
    <script>
        function one(num){
            var objs = document.getElementsByTagName("ul");
            for(var i = 0; i < objs.length;i ++) {
                if (i == num) {
                    objs[i].style.display = "block";
                }else {
                    objs[i].style.display = "none";
                }
            }
        } 
    </script>
</body>
</html>

 

Example017简单的下拉框

标签:

原文地址:http://www.cnblogs.com/handsomehan/p/5380551.html

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