Javascript examples for DOM HTML Element:Textarea
The cols property sets or gets the cols attribute of a text area, which controls the visible width of a text area, in characters.
Set the cols property with the following Values
Value | Description |
---|---|
number | Sets the width of the text area. Default is 20 |
A Number, representing the width of the text area, in characters
The following code shows how to change the width of a text area:
<!DOCTYPE html> <html> <body> <textarea id="myTextarea" rows="4" cols="50"> new value/*w w w . ja v a2s .co m*/ </textarea> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myTextarea").cols = "100"; } </script> </body> </html>