5

I am trying to detect whenever the user resizes a resizable textarea..

I am trying to do it with this code but it doesn't work:

$('textarea.note').bind("resize", function(){

  alert("resize!!!!!");


})

I don't want really to use any kind of timer and loops.. Help!?

John Black
  • 305
  • 2
  • 8
  • 18

1 Answers1

10

DEMO

$(document).ready(function () {
    var $textareas = jQuery('textarea');

    // set init (default) state   
    $textareas.data('x', $textareas.outerWidth());
    $textareas.data('y', $textareas.outerHeight());

    $textareas.mouseup(function () {

        var $this = $(this);

        if ($this.outerWidth() != $this.data('x') || $this.outerHeight() != $this.data('y')) {
            alert($this.outerWidth() + ' - ' + $this.data('x') + '\n' + $this.outerHeight() + ' - ' + $this.data('y'));
        }

        // set new height/width
        $this.data('x', $this.outerWidth());
        $this.data('y', $this.outerHeight());
    });
});
Tushar Gupta - curioustushar
  • 56,454
  • 22
  • 99
  • 107