setInterval实现闪烁的文字

<!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 txt = document.getElementById("text"),
            num = 0;
            setInterval(function(){
                if(num==0){
                    txt.innerHTML='今日特卖';
                    num=1;
                }else{
                    txt.innerHTML='今日特卖';
                    num=0;
                }         
            },500);
            
        </script>
    </body>
</html>

 

    原文作者:玛丽大
    原文地址: https://blog.csdn.net/qq_36937220/article/details/101212597
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞