Get the width of the text area, in characters:
var x = document.getElementById("myTextarea").cols;
Click the button to display the value of the cols attribute of the text area.
<!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> <p id="demo"></p> <script> function myFunction() {//from w ww .j av a 2s.c o m var x = document.getElementById("myTextarea").cols; document.getElementById("demo").innerHTML = x; } </script> </body> </html>