You are here: Reference > JavaScript > client-side > HTML DOM > properties > loop (bgsound, img, input:image)
loop property (bgsound, img, input:image)
Specifies or returns the number of repeats for a sound or video clip.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: loop |
Possible values:
The 'infinite' string constant or an integer that sets or retrieves the number of repeats.
One of the following values:
Repeats infinitely. | |||||||
Repeats infinitely. | |||||||
Repeats only once. | |||||||
Positive integer, the number of repeats. |
Default: 1.
Example HTML code 1:
This example illustrates the use of the loop attribute:
|
||||
<bgsound id="myBgSound" src="budgie.wav" loop="0"> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the loop property:
|
||||
<head> <script type="text/javascript"> function ChangeLoop () { var bgSound = document.getElementById ("myBgSound"); if ('loop' in bgSound) { bgSound.loop = 3; } else { alert ("Your browser doesn't support this example!"); } } </script> </head> <body> <bgsound id="myBgSound" src="budgie.wav" loop="0"> <button onclick="ChangeLoop ();">Repeat it 3 times!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
External links:
User Contributed Comments