HTML DOM height 属性

定义和用法

height 属性可设置或返回图像的高度。

语法

  1. imageObject.height=pixels

实例

下面的例子可设置图像的高度和宽度:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeSize()
  5. {
  6. document.getElementById("compman").height="250"
  7. document.getElementById("compman").width="300"
  8. }
  9. </script>
  10. </head>
  11.  
  12. <body>
  13. <img id="compman" src="compman.gif" width="107" height="98" />
  14. <br /><br />
  15. <input type="button" onclick="changeSize()"
  16. value="Change size of image">
  17. </body>
  18.  
  19. </html>