Skip to content

Instantly share code, notes, and snippets.

@skowron-line
Last active December 16, 2015 08:09
Show Gist options
  • Save skowron-line/5404090 to your computer and use it in GitHub Desktop.
Save skowron-line/5404090 to your computer and use it in GitHub Desktop.
Simple tab emulator, find fields from selector and allows to skip between then.
var tab = function()
{
this.fields = $('input:not(:disabled):not([type="hidden"]):not([readonly="readonly"]), a, select:not(:disabled)');
this.current = 0;
}
$.extend(tab.prototype, {
forward: function() {
this.current++;
if(this.current > this.fields.length) {
this.current = 0;
}
return this.current;
},
back: function() {
this.current--;
if(this.current < 0) {
this.current = this.fields.length;
}
return this.current;
},
focus: function() {
this.fields[this.current].focus();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment