Good afternoon, I need to increase the rows in the textarea and increase the height of the block itself, if a new line has started (as in Skype). Is it possible to check whether a new line has started using jq? Thank.

  • You can decide "in the forehead." We take the length of the textarea block and the current font. We calculate the number of characters (k) that fit into the string and divide the existing number of characters by k. If the number is greater than 1,2,3, etc. it means there is a transition to a new line (1 2 3 and more rows are added accordingly). But there is the rows property, which in js can be obtained as textarea.rows and make +1 for all values ​​above 1. Read here (some attributes of html5 only) w3schools.com/jsref/dom_obj_textarea.asp - alexoander
  • The jacklmoore.com/autosize plugin does a similar thing. You can use it, you can see the code on Github . - Gleb Kemarsky
  • The fact is that there are different numbers of letters (Z ~ 65; z ~ 80), so this option is not suitable. - Qriti

1 answer 1

Found an answer to your question.
Maybe someone will come in handy: checking area.scrollTop (), if it grew, then I increase the rows and the size of the block itself.
Thanks to all

  • I just wanted to write about it, okay) - Yuri
  • An unusual decision - to check whether scrolled appeared =) But I agree) By the way - mark your answer as "the answer to the question". This is a tick next to <--- " - alexoander