运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The onseeking Event</h2> <p>Attach a "seeking" event to the video element.</p> <p>The currentTime property returns the position (in seconds) of the video playback.</p> <video id="myVideo" controls> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> <p>Seeked to position: <span id="demo">0</span></p> <p>Try to move to a new position in the video.</p> <script> // Get the video element with id="myVideo": const video = document.getElementById("myVideo"); // Attach a seeking event to the video element: video.addEventListener("seeking", myFunction); // Function to display the current position of the video: function myFunction() { document.getElementById("demo").innerHTML = video.currentTime; } </script> </body> </html>