我想禁用鍵盤上的「Enter」按鈕,這樣當用戶按Enter鍵提交表單時,什麼都不會發生,並且執行其他操作而不是提交表單,例如作爲警告「使用鍵盤不被允許」。jQuery禁用鍵盤上的提交按鍵
這裏是我做了什麼,#calculator
一個按鈕:
$(document).ready(function(){
$("#calculator").keydown(function(){
console.log("Enter is disabled.");
return false;
});
});
目前在其提交表單結果意外(例如重定向到目標頁面,但沒有加載任何CSS
你有一些代碼嗎? – i100
在鍵盤事件中返回'false'鍵碼13 – goseo