Javascript examples for CSS Style Property:width
Return the width of an <img> element:
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/c.png" style="width:100px;height:132px;"> <br> <button type="button" onclick="myFunction()">Return width of image</button> <script> function myFunction() {/*from w w w . j ava 2 s.c om*/ console.log(document.getElementById("myImg").style.width); } </script> </body> </html>