我有一个简单的输入框,如果数字大于 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/