Created
February 20, 2013 11:38
-
-
Save spritle/4994938 to your computer and use it in GitHub Desktop.
It is a small and simple plugin which Capitalize all the text inside a table.
The plugin also has the option to convert all words to small letters.
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
(function($) { | |
$.fn.tableCap = function(params) { | |
params = $.extend( {lower : false, toggle : true}, params); | |
var selectedElement = $(this); | |
toggleText = (function (convert) { | |
$('tr td',selectedElement).each(function () { | |
convert($(this).html(), $(this)) | |
}); | |
}); | |
var Changetext = { | |
convertTolower : function() { | |
toggleText( (function(element_text, element) { | |
element.html(element_text.toLowerCase()); | |
}) ) | |
}, | |
convertToupper : function() { | |
toggleText( (function(element_text, element) { | |
element.html(element_text.charAt(0).toUpperCase() + element_text.substring(1).toLowerCase()) | |
}) ) | |
} | |
} | |
params.lower ? Changetext.convertTolower() : Changetext.convertToupper(); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment