Javascript DOM CSS Style height Property set image height

Introduction

Change the height and width of an <img> element:

View in separate window

<!DOCTYPE html>
<html>
<body>

<img id="myImg" src="image1.png" width="100" height="132">
<br>

<button type="button" onclick="myFunction()">Change height and width of image</button>

<script>
function myFunction() {//  w  w w  .ja  v a2  s.c o m
  document.getElementById("myImg").style.height = "200px";
  document.getElementById("myImg").style.width = "200px";
}
</script>

</body>
</html>



PreviousNext

Related