Javascript DOM HTML Textarea rows Property set

Introduction

Change the number of visible rows for a text area:

document.getElementById("myTextarea").rows = "10";

Click the button to change the number of visible rows for the text area.

View in separate window

<!DOCTYPE html>
<html>
<body>

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

<script>
function myFunction() {/*from   w w w. j  av  a  2  s.c  o  m*/
  document.getElementById("myTextarea").rows = "10";
}
</script>

</body>
</html>

The rows property sets or gets the value of the rows attribute of a text area.

The rows attribute set the visible number of lines for a text area.

Value Description
number Specifies the visible number of rows in the text area

The rows property returns a Number representing the height of the text area, in characters.




PreviousNext

Related