嗨,有人能帮我弄清楚如何停止运行一个函数,直到按下特定数量的字符吗?
目前正在使用以下功能:
$('input#q').keyup
这会在您按下任意键后立即生效...
最佳答案
像这样的东西应该在添加 3 个字母后开始触发代码:
JavaScript
$('input#q').keyup( function() {
if( this.value.length < 4 ) return;
/* code to run below */
$('#output').val(this.value);
});
HTML
<input id="q" />
<br /><br />
<input id="output"/>
关于javascript - 第三个字符后的 Action 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4511085/