为了账号安全,请及时绑定邮箱和手机立即绑定

如何获得播放按钮以在 Javascript 上继续计时器?

如何获得播放按钮以在 Javascript 上继续计时器?

月关宝盒 2021-06-09 13:08:13
我试图简单地让我的播放按钮起作用,但我不知道如何。我通过添加clearInterval(timer)让我的暂停按钮工作,所以我猜我做了相反的事情?我曾尝试加入countDown对playTimer功能tick的addEventListener,但那些不工作。var startButton = document.getElementById("start");var startSound = document.getElementById("audio"); var timerSound = document.getElementById("timer");var counter = document.getElementById("counter");var pausePlay = document.getElementsByClassName("pausePlay");var pauseButton = document.getElementById("pause");var playButton = document.getElementById('play');var middleButtons = document.getElementsByClassName("middleButtons");var fiveMin = document.getElementById("fiveMin");var end = document.getElementById("endSess");var redo = document.getElementById("redo");function playAudio(){    startSound.play();}// Start button will disappear after click and countDown method will beginfunction startTimer(){    startButton.style.display="none";     counter.style.display = "";    for (var i = 0; i < pausePlay.length; i++) {        pausePlay[i].style.display = "block";      }    countDown(10);}// function play(){// }function countDown(minutes){    var seconds = 60;    var mins = minutes;    function tick(){        var current_minutes = mins - 1;        seconds --;        counter.innerHTML = current_minutes.toString() + ":" + (seconds < 10 ? "0" : "") + String(seconds);        if(seconds > 0){            timer = setTimeout(tick, 1);        } else {            if(mins > 1){                countDown(mins - 1);            }            else if (mins && seconds === 0 ){               timerSound.play();               for (var i = 0; i < pausePlay.length; i++){                pausePlay[i].style.display = "none";                }                options();            }        }    }        tick();  }// Pause timer  function pauseTimer(){    clearInterval(timer);  }// Continue timerfunction playTimer(){    countDown();}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 117 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信