table+js实现网站左侧列表下拉隐藏

    <script language="javascript">
          
         function showHide(obj){
        
         try
         {
            if (obj.id=="M_1")
            {
            
              document.getElementById(‘M_2‘).style.display="none";
              document.getElementById(‘M_3‘).style.display="none";
              document.getElementById(‘M_4‘).style.display="none";
           
            }
           
            if (obj.id=="M_2")
            {
            
              document.getElementById(‘M_1‘).style.display="none";
              document.getElementById(‘M_3‘).style.display="none";
              document.getElementById(‘M_4‘).style.display="none";
          
            }
           
             if (obj.id=="M_3")
            {
           
              document.getElementById(‘M_1‘).style.display="none";
              document.getElementById(‘M_2‘).style.display="none";
              document.getElementById(‘M_4‘).style.display="none";
          
            }
           
             if (obj.id=="M_4")
            {
           
              document.getElementById(‘M_1‘).style.display="none";
               document.getElementById(‘M_2‘).style.display="none";
              document.getElementById(‘M_3‘).style.display="none";
           
            }
            }catch(e)
            {
            }
          var oStyle = obj.style;
          oStyle.display == "none" ? oStyle.display = "block" : oStyle.display = "none";
         }

</script>

html代码

  <div>

 <table>

 <tr onclick="showHide(M_1)">

<td>下拉框1</td>

</tr>

 <tr>

<td>

<table id="M_1">

<tr><td>列表1</td></tr>

</table>

</td>

</tr>

<tr>

<td>

<table id="M_2">

<tr><td>列表2</td></tr>

</table>

</td>

</tr>

<tr>

<td>

<table id="M_3">

<tr><td>列表3</td></tr>

</table>

</td>

</tr>

<tr>

<td>

<table id="M_4">

<tr><td>列表4</td></tr>

</table>

</td>

</tr>

</table>

</div>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。