JavaScript 会闪烁的文字

代码如下:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>闪烁的文字</title>
    <style type="text/css">
        div{
            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>
原文地址:https://www.cnblogs.com/Lay0us/p/12066768.html