Change the width of an <object> element to 200px:
document.getElementById("myObject").width = "200";
Click the button to change the width of the object element to 200px.
<!DOCTYPE html> <html> <body> <object id="myObject" width="100" height="100" data="video.mp4" style="border:1px solid black"></object> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*ww w . j av a 2s. c o m*/ document.getElementById("myObject").width = "200"; } </script> </body> </html>
The width
property sets or gets the value of the width attribute of an <object> element.
The width attribute sets the width of an object.
Value | Description |
---|---|
pixels | Specifies the width of the object, in pixels (e.g. height="100") |
The width
property returns a Number representing the width of the object, in pixels.