0

I have multiple videos on my website that has multiple codecs for multiple browsers.

<video id="video2" width="480" height="270">
<source src="movies/vid2.ogv" type="video/ogg">
<source src="movies/vid2.webm" type="video/webm">
<source src="movies/vid2.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>

I only need to show one video at a time. so i have

onClick="changevid(A)

the onClick is working fine, changing the vids. but how do i change all 3 of them?

vid1.ogv vid1.webm vid1.mp4

i can only change 1 by doing
var A = 'movies/vid1.mp4';

function changevid(q){
    document.getElementById('video2').setAttribute('src', q);
}

Thanks

AndrewTsang
  • 286
  • 3
  • 17

1 Answers1

0

Maybe this helps:

var doc = document, bod = doc.body;
function E(e){
  return doc.getElementById(e);
}
function changevid(q){
  E('video2').src = q;
}
StackSlave
  • 10,198
  • 2
  • 15
  • 30
  • Hey, I'm not that good with programming yet, so i don't really understand the code. what's bod for? and it doesn't seem to change formats? – AndrewTsang Oct 24 '14 at 02:10
  • Just showing you how variables work. I put `document` in `doc` so `doc.body` is your `` tag. It's not in use here. – StackSlave Oct 24 '14 at 02:56