Javascript DOM HTML Video poster Property get

Introduction

Get the URL of the poster image:

var x = document.getElementById("myVideo").poster;

Click the button to return the value of the poster attribute of the video.

View in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="100" height="100" poster="image1.png" controls>
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>//from   w  ww .j a va 2  s  . c om
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myVideo").poster;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related