隐藏div只需要把该div层的display设置为’none’就可以,所以我们只需要在链接a中加入onclick的鼠标事件就可达到这个目的。再配合鼠标的cursor属性就更加完美了。

以下是代码

<style type=”text/css”>
#box{ padding:0 5px 0 5px;height:30px; width:500px; background-color: #FFFFDF; border:1px #FFFF99 solid; line-height:30px; color: #373737;}
#box span{ color:#FF0000;float:right;}
</style>

<div id=”box”><a onclick=”javascript:document.getElementById(‘box’).style.display=’none’” onmouseover=”this.style.cursor=’hand’”
><span>×</span></a>这是一段测试,点击右边的小红叉可以隐藏这段文字……</div>

以下是演示:

×这是一段测试,点击右边的小红叉可以隐藏这段文字……