Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Firefox OS 的新手。我有一个搜索框。
按下提交按钮后,它完美地显示了结果。但我想添加键盘事件,比如按下回车按钮,它会显示结果。
尝试这个:
$("#SearchText").keydown(function (e) { var keyCode = e.keyCode || e.which; if (keyCode == 13) { //stop CR & do submit here instead document.forms["myform"].submit(); return false; } });
它拦截搜索文本字段中的每个按键并检查是否返回。