JavaScript自动(定时)关闭(隐藏)DIV或指定标签代码

该代码的作用就是对特定内容定时关闭或自动隐藏,可以作为公告/广告特效。id加上gdGonggaoBox01的标签在指定时间后就属于不存在等同指定时间后那段代码清除

引用方法给指定DIV加上id="gdGonggaoBox01 这个ID

在合适区域放上关闭按钮

<a onclick="document.getElementById('gdGonggaoBox01').style.display='none';" href="#">关闭 </a>

自动关闭代码 javascript

<script type="text/javascript">
function hidengonggao()
{
document.getElementById('gdGonggaoBox01').style.display='none'
};
setTimeout(hidengonggao,30000);
//setInterval("timer.innerText--;if(timer.innerText<='0')timer.innerText=='0';",1000);
</script>

Relay Tips: 一极乐https://yijile.com/log/109/