Skip to content

Instantly share code, notes, and snippets.

@omichelsen
Created January 11, 2014 17:28
Show Gist options
  • Save omichelsen/8373905 to your computer and use it in GitHub Desktop.
Save omichelsen/8373905 to your computer and use it in GitHub Desktop.
jQuery formNavigtaion
(function ($) {
$.fn.formNavigation = function () {
$(this).each(function () {
$(this).find('input').on('keyup', function(e) {
switch (e.which) {
case 39:
$(this).closest('td').next().find('input').focus(); break;
case 37:
$(this).closest('td').prev().find('input').focus(); break;
case 40:
$(this).closest('tr').next().children().eq($(this).closest('td').index()).find('input').focus(); break;
case 38:
$(this).closest('tr').prev().children().eq($(this).closest('td').index()).find('input').focus(); break;
}
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment