JS關閉DIV
HTML
<div id="bar1">
<p onclick="removeElement('bar1')">關閉</p>
</div>
<div id="bar2">
<p onclick="removeElement('bar2')">關閉</p>
</div>
JS
<script type="text/javascript">
function removeElement(id)
{
document.getElementById(id).style.display="none";
}
</script>
JS顯示DIV
<div onclick="showOtherDiv()" style="border:1px solid #fff">點擊顯示另一個div</div>
<div id="otherDiv" style="display:none;border:1px solid red">點擊后顯示的div</div>
<script type="text/javascript">
function showOtherDiv(){
//獲取要顯示的div對象
var otherDiv=document.getElementById('otherDiv');
//顯示
otherDiv.style.display="block";
}
</script>