Easy way to count characters using .keyup in jQuery
2 answers
$('input').keyup(function() {
console.log(this.value.length);
});
keyupis a quick access method for bind('keyup').
And since jQuery 1.7 all of the above is deprecated, we recommend using the method onto bind events, which means that the code should look like this:
$('input').on('keyup', function() {
console.log(this.value.length);
});
+14