js-闪烁的文字

<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="UTF-8">
        <title>闪烁的文字</title>
        <style type="text/css">
            div{
                width:200px;
                height:200px;
                line-height:200px;
                border:2px solid gray;
                text-align:center;
                color:red;
            }
        </style>
    </head>
<body>
    <h3>会闪烁的文字</h3>
        <div id="text"> </div>
        <script type="text/javascript">
            var oText=document.getElementById("text");
            var num=0,timer=null;
            timer=setInterval(function(){
                if(num==0){
                    oText.innerHTML="☆☆☆今日特卖☆☆☆"
                    num=1
                }else{
                    oText.innerHTML="★★★今日特卖★★★"
                    num=0
                }
            },500)
        </script>
    </body>
</html>

猜你喜欢

转载自blog.csdn.net/asazyf/article/details/80686582