我试图简单地让我的播放按钮起作用,但我不知道如何。我通过添加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();}
添加回答
举报
0/150
提交
取消