<!DOCTYPE html>
<html>
<body>
<h2>HTML onplay Event Attribute Example</h2>
<p>Click on the play button to trigger the onplay event:</p>
<audio id="myAudio" controls onplay="myFunction()">
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "The audio has started playing.";
}
</script>
</body>
</html>
onplay
是一个事件属性,当 <audio>
或 <video>
元素开始播放时触发。onplay
事件,并调用 JavaScript 函数 myFunction()
。myFunction()
函数会在页面上显示一条消息,表明音频已经开始播放。上一篇:innerhtml
下一篇:html网页制作代码大全
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站