用JS点radio 实现div显示 隐藏   

解决方案 »

  1.   

    document.getElementById('divid').style.display = 'none' //隐藏
    document.getElementById('divid').style.display = 'block' //显示
      

  2.   


    <input type="radio" onclick="yclick()">隐藏
    <input type="radio" onclick="xclick()">显示
    function yclick(){
       document.getElementById("div1").style.display="none";
    }
    function xclick(){
       document.getElementById("div1").style.display="block";
    }
      

  3.   


       document.getElementById("div").style.display="none";   document.getElementById("div").style.display="block";
      

  4.   

    随便做的一个简单例子,可以拷贝下来运行看效果:<!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    function disDiv(obj){
    if(obj.value==1){
    document.getElementById("DivT").style.display="block";//显示
    }else{
    document.getElementById("DivT").style.display="none";//隐藏
    }
    }
    </script>
    </head><body>
    <input type="radio" name="rad" value="1" checked onclick="disDiv(this)"/>显示
    <input type="radio" name="rad" value="2" onclick="disDiv(this)"/>隐藏
    <div id="DivT" style="display:block">
    <img src="http://xiami.com/images/album/img58/7158/3394741249024636.jpg" />
    </div></body>
    </html>
      

  5.   

    将js写到radio的click事件就ok了嘛!!