javascript 页面加载后如何删除或隐藏div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27893156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to remove or hide div after page loading
提问by Nastaran
this div add to source of my web page after loading. can i use some code to hide or remove that?
这个 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&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&n=a8fcf057" border="0" />
</a>
</iframe>
<iframe style="width:1px; height:1px; margin:0; visibility:hidden;" src="http://persianbox.com/s.aspx?pscn=2&pscr=moured.persianblog.ir&psct=&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>
回答by jmore009
with Jquery:
使用 Jquery:
$("#divADV").hide()
or with plain javascript:
或使用普通的 javascript:
document.getElementById(divADV).style.display = 'none';
but you're better off just doing this in css:
但你最好只在 css 中这样做:
#divADV{
display: none;
}
回答by Ahmad Sharif
Here your targer div will hide after 3 second. you can set it 2 or 1 sec or set 0 to hide just after loading by changing the value
在这里,您的目标 div 将在 3 秒后隐藏。您可以通过更改值将其设置为 2 或 1 秒或设置 0 以在加载后立即隐藏
$(document).ready(function() {
$('#targetDiv').delay(3000).hide();
});