babiro babiro - 1 year ago 97
CSS Question

Maximum height of textarea to 300px (Javascript)

I can't make a maximum height limit to 300px of textarea which height varies.


Thanks in advance.

Answer Source

It's simply a matter of checking the height prior to resizing. If you would like to eliminate scrollbar flicker consider setting overlflow-y to hidden until 300:

function resize () {

    var height = text.scrollHeight <= 300 ? text.scrollHeight : 300; = height+'px';


fiddle -

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download