我想问一问为什么会有多重响应?我怎样才能输入输入字段只有一个响应?javascript keypress多记录问题
期望:在输入字段中输入数据并按下回车键,它将执行操作。
$("#textInput").keypress(function (e) {
console.log("123");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<input type='text' id='textInput'/>
[jQuery keypress事件在持有密钥时会重复触发 - 但不会在所有密钥上触发](https:// stackoverflow。com/questions/9098168/jquery-keypress-event-fires-repeated-when-key-is-held-but-not-all-keys) –
我不同意重复的建议。 –