[問題] 弱弱的問個setInterval的問題
<audio id="audio" src="1.mp3"></audio>
<input type="submit" onclick="int" />
<button onclick="clearInterval(int)">Stop interval</button>
<script>
var audio = document.getElementById("audio");
var int;
int = setInterval("play()", 1000);
function play() {
audio.play();
}
</script>
我想製作一個每秒響一次的程式
有2個問題想請教
1. 如何讓它不要載入後自動執行,等我點擊再開始播放?
2. 當我運行clearInterval之後,為什麼沒辦法再次執行setInterval了?
新手發問,還請版上大大指點一二
--
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 104.237.91.182
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1479487654.A.B9C.html
※ 編輯: iamshuichi (104.237.91.182), 11/19/2016 00:48:12
→
11/19 01:38, , 1F
11/19 01:38, 1F
→
11/19 11:05, , 2F
11/19 11:05, 2F
→
11/19 11:05, , 3F
11/19 11:05, 3F
→
11/19 11:05, , 4F
11/19 11:05, 4F
→
11/19 11:06, , 5F
11/19 11:06, 5F
→
11/19 11:08, , 6F
11/19 11:08, 6F
→
11/19 11:08, , 7F
11/19 11:08, 7F
→
11/19 11:09, , 8F
11/19 11:09, 8F
→
11/19 11:09, , 9F
11/19 11:09, 9F
→
11/19 11:09, , 10F
11/19 11:09, 10F
→
11/19 11:10, , 11F
11/19 11:10, 11F
→
11/19 11:10, , 12F
11/19 11:10, 12F
→
11/19 11:10, , 13F
11/19 11:10, 13F
→
11/19 11:10, , 14F
11/19 11:10, 14F
→
11/19 11:11, , 15F
11/19 11:11, 15F
→
11/19 11:11, , 16F
11/19 11:11, 16F
→
11/19 11:11, , 17F
11/19 11:11, 17F
→
11/19 11:11, , 18F
11/19 11:11, 18F
→
11/19 13:58, , 19F
11/19 13:58, 19F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章