Skip to content

Instantly share code, notes, and snippets.

@dotmh
Created June 8, 2012 08:56
Show Gist options
  • Save dotmh/2894587 to your computer and use it in GitHub Desktop.
Save dotmh/2894587 to your computer and use it in GitHub Desktop.
A Jquery Alpha range plugin
(function($){
$.alphaRange = function(from , to , onlyLetters) {
var startLetter = from || 'A',
endLetter = to || 'Z',
start = startLetter.charCodeAt(0),
end = endLetter.charCodeAt(0),
length = end - start,
letter = 0,
alphaOnly = onlyLetters || true,
alphaRange = [];
for ( letter; letter <= length; letter++) {
currentLetter = String.fromCharCode(start + letter);
if ( !alphaOnly || (alphaOnly && currentLetter.match(/[A-Za-z]/m))) {
alphaRange.push(currentLetter);
}
}
return alphaRange;
}
})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment