html中如何隐藏ID的内容而显示其下子ID内容?

来源:百度知道 编辑:UC知道 时间:2024/05/22 04:51:59
<span id="a">aaa
<span id="b">bbb</span>
</span>

----------------
如上,如果我想隐藏这个内容可以先加上:
<style>#a{DISPLAY: none;}</style>
但这样做aaa,bbb都隐藏了,如果我想只隐藏aaa,而显示bbb有什么办法吗?

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style>
.t
{
border:1px solid red;
width:200px;
height:200px;
position:absolute;
top:50px;
left:100px;
display:block;
}
.d
{
border:1px solid black;
width:500px;
height:500px;
display:none;
}
</style>

</HEAD>

<BODY>
<button onclick="swap_node();">Swap</button>
<div class="d" id="div1">
<span class="t" id="test" style="display:block;">test</span></div>
</BODY>
</HTML>
<script >
var newNode=document.createElement("div");
var $=function(id)
{
return document.getElementById(id)
}
document.body.onload=function()
{
document.body.appendChild(n