Toggle the Table Column Visibility

Posted by Karaniscool under jQuery category on | Points: 40 | Views : 3491
//Toggle any particular <td> column from the <table> table. Visibility property of the CSS ie being used here. You can also use the display property, if you want
//to save the space on the webpage.
//Over here you have to pass the html table id, column id and the visibility state.

function ToggleColumn(tblId, tdId, visState) {
$('#' + tblId + ' tr').each(function() {
$(this).find('td[id*="' + tdId + '"]').css("visibility", visState); //Attribute Contain Selector ([id*=) used for id value.
}); }

ToggleColumn('tblCat', 'tdCatReq', 'hidden');
ToggleColumn('tblCat', 'tdCatReq', 'visible');

Comments or Responses

Login to post response