Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Nút dừng (stop) cho HTML5 audio control


Thử mã sau để thêm nút dừng cho audio HTML5:

function displayStopBtn() {    var myPlayer = document.getElementsByTagName('audio')[0];    myPlayer.pause();    myPlayer.currentTime = 0; }

Cũng có thể dùng jQuery:

$("#stopButton").click(function () {    audio.pause();    audio.currentTime = 0; });