9

I'd like to monitor my textarea's changes with jQuery. I can do this with the keyup event and it works perfectly. But what event I can get when a user click on the textarea (right mouse click), then choose paste?

Click event occur only when the user click with the left mouse button on the textarea.

How can I handle this situation?

Colby77
  • 617
  • 1
  • 8
  • 10

1 Answers1

10

you can detect Pastes or Cuts into the textarea by:

$("#TextBox1").bind('paste', function(e) {
            alert('pasting text!');
        });
$("#TextBox1").bind('cut', function(e) {
            alert('cut text!');
        });

Or combine:

$("#Text1").bind('cut paste', function(e) {
    alert(e.type + ' text!');
});
Glennular
  • 17,827
  • 9
  • 58
  • 77
  • 5
    It doesn't work for me. But it's close, so I'll accept it. The right answer : $("#TextBox1").bind('input paste', function(e) {...}); – Colby77 May 13 '10 at 20:33
  • I used just `...bind("input cut paste"...` and it works like a charm - typing, cut & paste using the keyboard or context menu; even drag/drop of text. – Lawrence Dol Feb 13 '13 at 08:48