日期:2014-05-18  浏览次数:20772 次

求一个标签问题/50分
因为我要根据条件让页面的内容显示或者隐藏

我现在页面有一个tr标签的横线
<tr   align= "center ">
<td   height= "20 "   colspan= "8 "> <hr   width= "100% "   size= "1 "> </td>
</tr>

我想隐藏这块,就是让页面显示的时候,这个地方的空间隐藏。请问,javascript应该怎样写?

------解决方案--------------------
放到div里面去,然后把div隐藏掉啊
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var prediv= " ";
function showKind()
{
var e=document.form1.myselect.options[document.form1.myselect.selectedIndex].value;

if(prediv!= " ")
{
eval( "document.getElementById( ' "+prediv+ " ').style.display= 'none ' ");
eval( "document.getElementById( ' "+e+ " ').style.display= 'block ' ");
prediv=e;

}
else
{
eval( "document.getElementById( ' "+e+ " ').style.display= 'block ' ");
prediv=e;

}

}
//-->
</SCRIPT>
<BODY>
<FORM METHOD=POST ACTION= " " name= "form1 ">


<SELECT id= "myselect " onchange= "showKind() ">
<option value= " "> 请选择 </option>
<option value= "fruit "> 水果 </option>
<option value= "hobby "> 爱好 </option>
<option value= "book "> 喜欢的书脊 </option>


</SELECT>

<div id= "mydiv " style= "position:absolute;left:10;top:50;border:1 solid red;width:300;height:200;background-color:#cccccc ">
<div id= "fruit " style= "position:relative;left:0;top:10;display:none ">
<INPUT TYPE= "checkbox " NAME= "1 "> 苹果 <INPUT TYPE= "checkbox " NAME= "1 "> 西瓜 <INPUT TYPE= "checkbox " NAME= "1 "> 番茄
</div>
<div id= "hobby " style= "position:relative;left:0;top:10;display:none ">
<INPUT TYPE= "checkbox " NAME= "1 "> 打篮球 <INPUT TYPE= "checkbox " NAME= "1 "> 游泳 <INPUT TYPE= "checkbox " NAME= "1 "> 高二伏
</div>
<div id= "book " style= "position:relative;left:0;top:10;display:none ">
<INPUT TYPE= "checkbox " NAME= "1 "> 电脑书籍 <INPUT TYPE= "checkbox " NAME= "1 "> 杂志 <INPUT TYPE= "checkbox " NAME= "1 "> 程序
</div>

</div>
</FORM>
</BODY>
</HTML>


------解决方案--------------------
<tr align= "center " style= "display:none ">
<td height= "20 " colspan= "8 "> <hr width= "100% " size= "1 "> </td>
</tr>
------解决方案---------