Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change HTML5 video tag width and height through Javascript

I have the following code in client side JS:

$(function() {
  $("#player1").html(
    '<video width=' + width + ' height=' + height + ' autoplay>' +
      '<source src=' + curPlayListHrefs[0] + ' type="video/youtube"></source>' +
    '</video>'
  );
});

I tried:

  var video = document.getElementsByTagName("video")[0];
  video.videoHeight = 300;
  video.videoWidth = 700;

Is it possible for me to change the width/height of the video tag?

like image 842
gaurav jain Avatar asked Feb 14 '13 06:02

gaurav jain


1 Answers

Try setting its width and height attributes

var video = document.getElementsByTagName("video")[0];
video.setAttribute('height', '300');
video.setAttribute('width', '700');

or setting its width and height properties

var video = document.getElementsByTagName("video")[0];
video.height = 300;
video.width = 700;
like image 183
Musa Avatar answered Nov 15 '22 03:11

Musa