Skip to content

Instantly share code, notes, and snippets.

@xuncheng
Created January 2, 2014 14:07
Show Gist options
  • Save xuncheng/8219632 to your computer and use it in GitHub Desktop.
Save xuncheng/8219632 to your computer and use it in GitHub Desktop.
Keyboard Navigation between Input Fields using JQuery: enter key
// Need dom_element_find.js
// https://gist.github.com/xuncheng/8219581
$("input[type=text]").bind("keydown", function(event) {
var target;
if (event.keyCode === 13) {
target = $("input[type=text]").elementAfter(this);
if (target) {
target.select().focus();
}
event.preventDefault(); // 禁用提交事件
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment