Javascript DOM HTML Textarea set height and width via css style

Introduction

Change the height and width of a text area using the style.width and style.height properties:

Click the button to change the width and height of the text area.

View in separate window

<!DOCTYPE html>
<html>
<body>

<textarea id="myTextarea">
At java2s.com you will learn how to make a website. 
</textarea>
<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from  ww w  . j av  a2s.  c o m*/
  document.getElementById("myTextarea").style.height = "100px";
  document.getElementById("myTextarea").style.width = "500px";
}
</script>

</body>
</html>



PreviousNext

Related