allienworks
4/8/2016 - 7:45 AM

Dynamically calculate height of video, based on its width (responsive).

Dynamically calculate height of video, based on its width (responsive).

function setVideoHeight() {
  var video = $('.video-js'),
      videoW = video.width(),
      videoH = videoW / 16 * 9;
  video.css({
    "height": videoH + "px",
  });
}
setVideoHeight();

$(window).resize(function() {
  setVideoHeight();
});