$('body').on('keydown', 'input, select', function(e) { if (e.which === 13) { var self = $(this), form = self.parents('form:eq(0)'), focusable, next; focusable = form.find('input, select, button, a').filter(':visible:enabled'); next = focusable.eq(focusable.index(this)+1); if (next.length) { next.focus(); } return false; } });