I think with jQuery .index() and .eq() you could do this pretty easily:
(function($){ $.fn.colorColumn = function(headerText, color){ var index = this.find("th").filter(function(){ return ($(this).text() == headerText); }).css("backgroundColor", color).index(); this.find("tr").each(function(){ $(this).children().eq(index).css({backgroundColor: color}); }) } })(jQuery); $("table").colorColumn("number", "red");
working demo: http://jsfiddle.net/pitaj/eG5KE/
source share