Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每当使用 HTML5 播放音频文件时,我都想运行一个 javascript 函数。我该怎么做?
如果可能的话,也可以看视频!
HTML5audio元素包含onplay事件。您可以按如下方式绑定到它:
audio
onplay
var myAudio = document.getElementById('audio_element'); myAudio.onplay = function(e) { // Your JavaScript function here... };
该video元素还包括此事件。
video