English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The loop attribute is a mapping of the HTML5 video tag's loop attribute, which determines whether the media element restarts after playing to the end.
HTML Audio/Video DOM Reference Manual
Set video to loop play:
<!DOCTYPE html> <html> <head> <meta charset="utf-8">-8"> <title>HTML Audio</title>/HTML5 video loop attribute usage-Basic Tutorial(oldtoolbag.com)</title>/<title> </<head> <body> <button onclick="enableLoop()" type="button">Enable Loop</button> <button onclick="disableLoop()" type="button">Disable Loop</button> <button onclick="checkLoop()" type="button">Check Loop Status</button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video.5 Your browser does not support HTML5 video.5 video tag. </video> <script> myVid=document.getElementById("video1); function enableLoop() { myVid.loop=true; myVid.load(); } function disableLoop() { myVid.loop=false; myVid.load(); } function checkLoop() { alert(myVid.loop); } </script> </body> </html>Test to see ‹/›
loop attribute sets or returns audio/Whether the video should replay after playback is complete.
IEFirefoxOperaChromeSafari
All mainstream browsers support the loop attribute.
Note:Internet Explorer 8 And earlier versions do not support this attribute.
Set loop attribute:
audio|video.loop=true|false
Return loop attribute:
audio|video.loop
Value | Description |
---|---|
true | Indicates the audio/The video should replay at the end. |
false | Default. Indicates the audio/The video should not replay at the end. |
Return value: | Boolean value, true|false |
---|---|
Default value: | false |