Javascript DOM HTML Textarea cols Property set width and height via CSS

Introduction

Change the width and height 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() {//ww  w .  j ava  2s .  co m
  document.getElementById("myTextarea").style.height = "100px";
  document.getElementById("myTextarea").style.width = "500px";
}
</script>

</body>
</html>



PreviousNext

Related