11.30setTimeout

2016-12-02  本文已影响0人  overisover

setTimeout

setTimeout(function(){},1000)//隔一秒后执行函数;类似闹钟;
广告弹出效果:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    div{
        width:400px;
        height:400px;background:#fbb;
        position:fixed;
        right:0px;
        bottom:0px;
        display:none;
    }
    </style>
    
</head>
<body>
    <div></div>
    <script>
        var oDiv=document.getElementsByTagName('div')[0];
        setTimeout(function(){
            oDiv.style.display='block';
            setTimeout(function(){
                oDiv.style.display='none';
            },5000)
        },2000);

    </script>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读