height of textarea increases when value increased but does not reduce when value is decreased

Forums jQueryheight of textarea increases when value increased but does not reduce when value is decreased
Staff asked 2 years ago

Answers (1)

Add Answer
Prince Dhameliya Marked As Accepted
Staff answered 2 years ago

The minimum scrollHeight of a textarea is always going to be the height. To get an accurate scrollHeight, set the height to 1 first.

h.height(1).height(h[0].scrollHeight);

 

Subscribe

Select Categories