Reputation: 588
Why does this not work, while this works. The only diffrence is that in the second case, I added the video elements in the html file instead of adding them through the innerHTML method.
document.querySelector('#top').innerHTML = document.querySelector('#top').innerHTML + "<video id='vid" + id + "'></video>";
Should create this
<video id="vid0"></video>
<video id="vid1"></video>
But when looking at the debugging window in chrome, i see that in that when I create the video tags in javascript, the src element of the first video doesnt appear. Which not happens when i add them manually to the html.
Upvotes: 0
Views: 132
Reputation: 15269
Couple of problems (I think!):
for (var i = 0; i <= vids; i++)
vids
ends up being 2, so this is trying to set src for video[0], video[1] and video[2], whereas you've only created two videos.
Also in this:
height = video[id].videoHeight / (video[id].videoWidth / width);
video[id].videoHeight
is not defined, so the height ends up being NaN.
Upvotes: 1