Audio loop attribute
Example
Set the audio to loop playback:
document.getElementById("myAudio").loop = true;
Try it »
Definition and Usage
The loop attribute sets or returns whether the audio should play again when it ends.
This property reflects
When this attribute is used, the audio continues playing after it ends.
Note:
Browser support





All major browsers support the loop attribute.
Note: Internet Explorer 8 and earlier IE versions do not support this attribute.
Syntax
Return the loop attribute:
audioObject
.loop
Set the loop attribute:
audioObject
.loop=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Indicates whether the audio plays again when it ends.
|
Technical Details
| Return Value: | Boolean. Returns true if the audio loops, otherwise false. |
|---|---|
| Default value: | false |
More examples
Example
Check whether the audio plays again after finishing:
var x = document.getElementById("myAudio").loop;
x
The output is:
true
Try it »
Related pages
HTML Reference Manual: HTML
Audio object