开发者

Not able to count characters using jQuery

I know I hav开发者_JS百科e a similar post, but it only answered part of my problem.

Her is my challenge to you: Can you make the alert display the correct number of characters? Even when you press backspace?

Here is the code:

jQuery('#input_Name').keydown(function(e) {
  var count = $(this).val().length;
  alert(count+1);
});

Hint: The ascii key for backspace is 8 ( if (e.keyCode != 8) )

(I'm not able to get this right)


jQuery('#input_Name').keyup(function(e) {
  var count = $(this).val().length;
  alert(count)
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜