Last active
December 16, 2015 08:09
-
-
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.
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
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