请问如何给层加个关闭按钮,谢谢
代码如下:<div id="Layer2">
  <script type="text/javascript"><!--
google_ad_client = "pub-7693641693247086";
/* 300x250, 创建于 09-1-3 */
google_ad_slot = "8990281345";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

解决方案 »

  1.   

    可以用个事件让它隐藏起来,设个样式,style="display:none",或者写段JS清空里面的内容就可以了,还可以用它的父节点来删除它,为什么要关闭?
      

  2.   

    直接用jQuery方法$("#Layer2").hide();就可隐藏这个div,显示的话就用$("#Layer2").show();
    如果lz非要删除这个div的话就只有清空这个div里面的元素就行了$("#Layer2").html();
      

  3.   

    <div id="new_dialogue">
    <div id="infoDIV">
    <div style="width:200px;float:left;">&nbsp;</div>
    <div style="width:20px;float:left;" onclick="closeDIV()" onmouseover="this.style.cursor='hand'">关闭</div>
    </div>
    </div><script>
    function closeDIV() {
    var new_dialogue = document.getElementById("new_dialogue");
    new_dialogue.parentNode.removeChild(new_dialogue);
    }
    </script>
    <style type="text/css">
    #new_dialogue {
    margin: -250px 0 0 -250px;
    position: absolute;
    top: 50%;
    left: 50%;
    }
    #infoDIV {
    padding-top: 8px;
    padding-left: 30px;
    //background: transparent url(images/cart_info_bg.png) no-repeat scroll 0 0;
    background-color: red;
    width: 322px;
    height: 95px;
    position: absolute;
    margin-top:50px;
    margin-left:30px;
    }
    </style>
      

  4.   


    <div id="Layer2" ondbclick="this.style.display:none">
      <script type="text/javascript"><!--
    google_ad_client = "pub-7693641693247086";
    /* 300x250, 创建于 09-1-3 */
    google_ad_slot = "8990281345";
    google_ad_width = 300;
    google_ad_height = 250;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div>