猿问

我怎么实现点击点击p显示ul,再点击隐藏ul.看我下方代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  <title>Document</title>
    <style type="text/css">
      *{margin:0;
        padding:0;
        font-size:13px;
        list-style:none;
      }
       p{height:25px;
        width:80px;
        line-height:25px;
        font-weight:bold;
        background:red;
        border-bottom:1px solid #ccc;  
        padding-left:5px;
      }
      ul{
        display:none;
      }
      li{height:24px;
       line-height:24px;
       padding-left:5px;
     }
    </style>
    <script type="text/javascript">
      window.onload=function(){
        var obj=document.getElementById('d1')
        var obj1=document.getElementsById('d2')
        
    </script>
</head>
<body>
    <div>
      <p id="d1">菜单a</p>
      <ul id="d2">
        <li>a1</li>
        <li>a2</li>
        <li>a3</li>
      </ul>
      <p id="d1">菜单b</p>
      <ul id="d2">
        <li>b1</li>
        <li>b2</li>
        <li>b3</li>
      </ul>
    </div>
</body>
</html>

木易老三
浏览 2661回答 0
0回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答