运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The onratechange Event</h2> <p>Assign an "onratechange" event to a video element.</p> <p>Use the playbackRate property to change the speed of the video:</p> <video id="myVideo" width="320" height="240" autoplay controls onratechange="myFunction()"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video><br> <button onclick="setPlaySpeed()" type="button">Set video to be play in slow motion</button> <p id="demo"></p> <script> // Get the video element: const video = document.getElementById("myVideo"); // Set the playback speed to 0.3 (slow motion) function setPlaySpeed() { video.playbackRate = 0.3; } // Alert some text when the playing speed of the video is changed function myFunction() { document.getElementById("demo").innerHTML = "The playing speed of the video was changed."; } </script> </body> </html>