日期:2014-05-17  浏览次数:20911 次

页面元素是否显示的控制问题
<body>
<div   id= "txt_ctr "   style= "display:block; "> <input   type= "button "   name= "b1 "   value= "显示下面的输入框 "   onclick= "ctr() "> </div>
<div   id= "txt_input "   style= "display:none; "> <textarea   cols= "60 "   rows= "10 "> </textarea> </div>
<script   language= "javascript ">
function   ctr(){
myinput=document.getElementById( 'txt_input ');
myinput.style.display== 'block ';
myctr=document.getElementById( 'txt_ctr ');
myctr.style.display= 'none ';
}
</script>
</body>
运行这样的代码:问题是点击“b1”按钮,按钮不见了,下面的文本域也不显示,我想要的效果是:点击按钮,显示下面的文本域,隐去按钮
刚学这些,请多指教

------解决方案--------------------
<style type= "text/css ">
<!--
.sadf {
}
-->
</style>
<body>
<div id= "txt_ctr " style= "display:block; "> <input type= "button " name= "b1 " value= "显示下面的输入框 " onclick= "ctr() "> </div>
<div id= "txt_input " style= "display:none; "> </div>
<script language= "javascript ">
function ctr(){
myinput=document.getElementById( 'txt_input ');
myinput.outerHTML= " <textarea cols=60 rows=10> </textarea> ";
myctr=document.getElementById( 'txt_ctr ');
myctr.style.display= 'none ';
}
</script>
</body>