【发布时间】:2018-02-01 12:42:46
【问题描述】:
当我在 textarea 中输入第一个字符时,它仍然显示 0,第二个字符的 count 为 1。不知道为什么?我正在为此使用 keydown 事件。
$(".textArea").keydown(updateCount());
function updateCount() {
count = $(".textArea").val().length;
this.$countDiv.text(count + " of 240");
};
【问题讨论】:
-
如果使用keyup事件呢?使用 keyup 事件
-
keydown 在您按下键时计数。试试 keyup!
标签: javascript jquery textarea