Created
January 11, 2014 17:28
-
-
Save omichelsen/8373905 to your computer and use it in GitHub Desktop.
jQuery formNavigtaion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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