Image width Property - Change the height and width of an image to 300px: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Image width Property - Change the height and width of an image to 300px:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img id="myImg" src="http://java2s.com/resources/a.png" width="107" height="98">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from  w  w  w  .jav a 2s .c  o  m
    document.getElementById("myImg").height = "300";
    document.getElementById("myImg").width = "300";
}
</script>

</body>
</html>

Related Tutorials