Javascript: calculating the number of columns of a text field with a dynamic size

I have an HTML text area whose width is set to 100% of the browser window using CSS.

How can I calculate how many columns of text fit in a text box?

+3
source share
1 answer

The textOMA DOM object supports a method colsthat can be used to get or set the column number of a text field.

var numCols = document.getElementById('myTextArea').cols

Learn more about Textarea at w3cschools .

-2
source

Source: https://habr.com/ru/post/1712976/


All Articles