我想問一問爲什麼會有多重響應?我怎樣才能輸入輸入字段只有一個響應?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) –
我不同意重複的建議。 –