Questions tagged «onkeyup»

21
计算文本区域中的字符
我想计算文本区域中的字符,所以我做了: <textarea id="field" onkeyup="countChar(this)"></textarea> function countChar(val){ var len = val.value.length; if (len >= 500) { val.value = val.value.substring(0, 500); } else { $('#charNum').text(500 - len); } }; 我的代码有什么问题?这是行不通的!好吧,那是新手的笔迹,需要帮助。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.