Javascript DOM HTML Textarea rows Property set rows and columns

Introduction

Change the height and width of a text area using the cols and rows 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 w  ww.  java2  s  . c  o  m
  document.getElementById("myTextarea").cols = "100";
  document.getElementById("myTextarea").rows = "10";
}
</script>

</body>
</html>



PreviousNext

Related