如何在页面加载后删除或隐藏div

时间:2015-01-11 23:07:11

标签: javascript html hide

此div在加载后添加到我的网页源。我可以使用一些代码来隐藏或删除它吗?

<div style="border-right: #c6c8ca 1px solid; border-top: #c6c8ca 1px solid; left: 0px;z-index: 4000; border-left: #c6c8ca 1px solid; width: 485px; border-bottom: #c6c8ca 1px solid;position: absolute; top: 0px; height: 60px; background-color: #e9e9e9" id="divADV">
<table border="0" cellpadding="0" cellspacing="0" width="485">
    <tbody>
        <tr>
            <td style="width:468px" id="tdAdv">
                <iframe id="a3b67f12" name="a3b67f12" src="http://ads.adsready.com/www/delivery/afr.php?zoneid=9&amp;target=_blank" scrolling="no" style="z-index:4000; width:468px; height:60px; margin:0" allowtransparency="true" frameborder="0">
                    <a href="http://ads.adsready.com/www/delivery/ck.php?n=a8fcf057" target="_blank"><img src="http://ads.adsready.com/www/delivery/avw.php?zoneid=9&amp;n=a8fcf057" border="0" />
                    </a>
                </iframe>
                <iframe style="width:1px; height:1px; margin:0; visibility:hidden;" src="http://persianbox.com/s.aspx?pscn=2&amp;pscr=moured.persianblog.ir&amp;psct=&amp;psep=1" scrolling="no" target="_top" frameborder="0"></iframe>
            </td>
            <td style="width:16px; text-align:center; vertical-align:top"><img alt="close" src="http://persianbox.com/close.gif" id="imgClose" onclick="javascript:closeWindow();" style="cursor: hand">
            </td>
        </tr>
    </tbody>
</table>

2 个答案:

答案 0 :(得分:3)

使用Jquery:

$("#divADV").hide()

或使用普通的javascript:

document.getElementById(divADV).style.display = 'none';

但你最好只在css中执行此操作:

#divADV{
   display: none;
}

答案 1 :(得分:2)

这里你的目标div将在3秒后隐藏。您可以设置2或1秒或设置0以在加载后通过更改值隐藏

$(document).ready(function() {
    $('#targetDiv').delay(3000).hide();
});