1

I am using jQuery for my application.

I have used Keyup and Change events combined on a function. i.e. I have a textbox and whenever I type in it the word counts comes on top of it. So basically I have word count function which works on Keyup and Change events.

The problem is when I use mouse to paste some text in text box the count doesn't changes unless I press some key or I click elsewhere.

Here is my code :

events :
'keyup #IdOfTextbox'  : 'wordCounter'
'change #IdOfTextbox'  : 'wordCounter'
wordCounter() : =>
//Code for counting words in Text Box
Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Arpit Rawat
  • 1,749
  • 2
  • 17
  • 28

1 Answers1

0

Try the following:

$(document).ready(function(){
    $(".test").bind("paste keyup change", function() {
        console.log($(this).val().length);
    });
});
c4urself
  • 4,027
  • 20
  • 29