一、HTML代码如下:

<div class="timer" id="timer">
     <span style="color: black;">广告剩余:</span><span class="clock" style="color: red;">60</span><span style="color: black"></span>
</div>

二、JavaScript代码如下:

<script type="text/javascript">
    var t = 60;
    var time = document.getElementsByClassName("clock")[0];

    function time() {
        t--;
        time.innerHTML = t;
        if(t <= 0) {
            //隐藏该div
            document.getElementById("timer").style.display = "none";
            clearInterval(inter);
        }
    }
    var inter = setInterval("time()", 1000);
</script>