gpt4 book ai didi

javascript - 第三个字符后的 Action 键

转载 作者:数据小太阳 更新时间:2023-10-29 05:41:54 25 4
gpt4 key购买 nike

嗨,有人能帮我弄清楚如何停止运行一个函数,直到按下特定数量的字符吗?

目前正在使用以下功能:

$('input#q').keyup

这会在您按下任意键后立即生效...

最佳答案

像这样的东西应该在添加 3 个字母后开始触发代码:

Live Example

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com