Javascript DOM HTML Textarea cols Property set width and height

Introduction

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

</body>
</html>



PreviousNext

Related