点击展开关闭层效果
分类:电脑知识 发表于:2011-02-09 21:12:33 评论(5)
<script type="text/javascript">
function openP(_id)
{
var select_id = parseInt(_id.replace("box",""));
for (i=1;i<=4;i++)
{
if (i==select_id)
{
document.getElementById("box"+i).style.display = "block";
}
else
{
document.getElementById("box"+i).style.display = "none";
}
}
}
</script>
<a href="javascript:void(0)" onclick="openP(′box1′)">点击展开1</a>
<p id="box1" style="display:none">这里面放的是box1的内容.</p>
<p><a href="javascript:void(0)" onclick="openP(′box2′)">点击展开2</a></p>
<p id="box2" style="display:none">这里面放的是box2的内容.</p>
<a href="javascript:void(0)" onclick="openP(′box3′)">点击展开3</a>
<p id="box3" style="display:none">这里面放的是box3的内容.</p>
<p><a href="javascript:void(0)" onclick="openP(′box4′)">点击展开4</a></p>
<p id="box4" style="display:none">这里面放的是box4的内容.</p>