Search code examples
javascriptjqueryhtmlevents

Resize event for textarea?


The current versions of Firefox and Chrome include a drag handler to resize a <textarea> box. I need to capture the resizing event, I thought it would be easy with jQuery's resize() event, but it doesn't work!

I have also tried the normal onResize event, but the result is the same. You can try it on JSFiddle.

Is there a way to capture it?


Solution

  • You need to first make the textarea resizable before issuing the resize event. You can do that by using jQuery UI resizable() and inside it you can call the resize event.

    $("textarea").resizable({
        resize: function() {
            $("body").append("<pre>resized!</pre>");
        }
    });
    

    Check working example at http://jsfiddle.net/HhSYG/1/