W3School TIY
(请在下面的文本框中编辑您的代码,然后单击此按钮测试结果。)
编辑您的代码:
<!DOCTYPE html> <html> <body> <button onclick="hasVidEnded()" type="button">该视频播放是否已结束?</button> <br /> <br /> <video id="video1" controls="controls"> <source src="../example/html5/mov_bbb.mp4" tppabs="http://w3school.com.cn/example/html5/mov_bbb.mp4" type="video/mp4"> <source src="../example/html5/mov_bbb.ogg" tppabs="http://w3school.com.cn/example/html5/mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <script> myVid=document.getElementById("video1"); function hasVidEnded() { alert(myVid.ended); } </script> </body> </html>
查看结果: