Javascript examples for DOM HTML Element:Video
The width property sets or gets the width attribute of a video.
The width attribute sets the width of a video player, in pixels.
Set the width property with the following Values
Value | Description |
---|---|
pixels | Sets the width of the video player, in pixels (i.e. width="100") |
A Number, representing the width of the video, in pixels
The following code shows how to change the width of the video player:
<!DOCTYPE html> <html> <body> <video id="myVideo" width="320" height="240" controls> <source src="your.mp4" type="video/mp4"> <source src="your.ogg" type="video/ogg"> Your browser does not support the video tag. </video>/*from w w w.jav a 2s.co m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myVideo").width = '200'; } </script> </body> </html>