Skip to content

Instantly share code, notes, and snippets.

@mlangens
Created July 9, 2013 03:22
Show Gist options
  • Save mlangens/5954449 to your computer and use it in GitHub Desktop.
Save mlangens/5954449 to your computer and use it in GitHub Desktop.
wrap around box changer
this.inputChanger = function() {
$(window).on('keydown', function(event) {
if(event.which === 13) {
var target = $(event.target);
var thingie = target.closest('.lightbox-container');
var inputs = thingie.find('input,textarea');
var index = inputs.get().indexOf(event.target);
var nextIndex = (index + 1) % inputs.length;
$(inputs.get(nextIndex)).focus();
return false;
} else if(event.which === 27) {
self.lightBox.close();
return false;
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment