Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  125] [ 5]  / answers: 1 / hits: 47207  / 13 Years ago, sat, february 4, 2012, 12:00:00
<input type=text />


How can I write the number of characters from input on .keyup in JavaScript/jQuery?


More From » jquery

 Answers
50
$('input').keyup(function() {
console.log(this.value.length);
});


keyup is a shortcut method for bind('keyup').

And as of jQuery version 1.7, all of the above are deprecated we are encourage to use the on method to bind events, meaning that the code should look like this:



$('input').on('keyup', function() {
console.log(this.value.length);
});

[#87645] Thursday, February 2, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nicole

Total Points: 648
Total Questions: 95
Total Answers: 103

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;