gpt4 book ai didi

javascript - 警报后重置输入值 - Javascript

转载 作者:行者123 更新时间:2023-12-01 06:59:28 24 4
gpt4 key购买 nike

我有一个简单的输入框,如果数字大于 2,则会出现一条弹出消息。

这是我正在使用的代码,但是我已经有一个 onkeyup命令输入其他内容,所以我希望这不会成为问题

HTML:

<input id="jj_input23" type="text" value='' onkeyup='changeTransform()' />

Javascript:
if(jj_input23 > 2) {
alert("Making the scale higher than 2 will make the preview too big");
document.getElementById('jj_input23').value("");
}

在显示警报消息并且用户单击“确定”后,我希望重置输入文本。我怎样才能做到这一点?

提前致谢

最佳答案

if(jj_input23 > 2) {
alert("Making the scale higher than 2 will make the preview too big");
document.getElementById('jj_input23').value = "";
}

如果您使用的是 jQuery,那么您几乎得到了它:
$('#jj_input23').val("");

关于javascript - 警报后重置输入值 - Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10923719/

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