代码如何写
CheckBox选中显示DIV没有选中不显示DIV

解决方案 »

  1.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
     <head>
      <title> New Document </title>
     </head> <body>
      <input type="checkbox" onclick="showdiv(this);" />
      <div id="div" style="display:none;width:100px;height:100px;border:solid 1px red;">我是div</div>
      <script type="text/javascript">
    function showdiv(ch){
    if(ch.checked){
    document.getElementById("div").style.display="block";
    }
    else{
    document.getElementById("div").style.display="none";
    }
    }
      </script>
     </body>
    </html>
      

  2.   

    如下例子:
    function xx()//限用选项卡显示

      if(Form1.selecta1.value=="1")
       { Form1.selecta1.value=0;
         document.all.xy.style.display='';  
       }
      else
       { Form1.selecta1.value=1;
         document.all.xy.style.display='none'; 
       }}<input type="checkbox" name="zzcx" onClick="javascript:zz()" value="1">可组装拆卸<input type="hidden" name="selecta1" value="1">