| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Document</title>    <style>         * {            margin: 0;            padding: 0;            list-style: none;         }         h2 {            width: 200px;            height: 80px;            text-align: center;            line-height: 80px;            background: purple;            color: #fff;            margin-top: 15px;         }         ul {            display: none;         }    </style></head><body>    <div id="container">        <h2>管理区</h2>        <ul>            <li>我的项目1</li>            <li>我的项目2</li>            <li>我的项目3</li>            <li>我的项目4</li>        </ul>        <h2>提交区</h2>        <ul>            <li>我的内容1</li>            <li>我的内容2</li>            <li>我的内容3</li>            <li>我的内容4</li>        </ul>    </div>    <script>        var h2 = document.querySelectorAll("h2");        console.log(this); // this 在全局 指向windows        for(var i=0;i<h2.length;i++) {            h2[i].onclick = function() {                // this在点击事件与类似事件 执行当前对象                 console.log(this); // h2                var uls = this.nextElementSibling;                if(uls.style.display == 'none') {                    uls.style.display = 'block';                } else {                    uls.style.display = 'none';                }            }        }    </script></body></html>
 |