Reputation: 177
hello i have a html5 video.
this is a example
<video width="320" id="video" height="240" controls>
<source src="video.mp4" type="video/mp4">
<source src="video1.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
</video>
i would a list of "source"
i'm write this code
var videotag = document.getElementsById('video'));
for (k = 0; k < videotag.childNodes.length; k++)
{
alert(videotag.childNodes[k]);
}
but not have a source. it is correct childNodes?
Upvotes: 0
Views: 253
Reputation: 943193
The method is getElementById
(singular), you have an extra )
on line one of your JavaScript, you have a global k
for no apparent reason, and childNodes
will give you all the child nodes, not just the source elements so you should probably be using querySelectorAll('source')
instead.
Upvotes: 2