function makeTableFluid(container) { function processTable(tableNode) { var $table = jQuery(tableNode); if ($table.data('isFluid')) { return; } $table.data('isFluid', true); var i, j, ic, row, cell; var headerText = [], headers = tableNode.querySelectorAll("thead th"), tableBody = tableNode.querySelector("tbody"); for (i = 0, ic = headers.length; i < ic; i++) { var current = headers[i]; current.innerHTML = current.innerHTML.replace(/()+/g, " "); headerText.push(current.textContent.replace(/\r?\n|\r/, "")); } for (i = 0; row = tableBody.rows[i]; i++) { for (j = 0; cell = row.cells[j]; j++) { if (headerText[j] != undefined) { cell.setAttribute("data-th", headerText[j]); } jQuery(cell).wrapInner(''); } } } container = jQuery(container); if (container.is('table')) { processTable(container.get(0)); } else { container.each(function (idx, node) { processTable(node); }); } } // jQuery(document).ready(function () { // makeTableFluid('#content-area table'); // }); jQuery('#content-area table').each(function(){ if ($(this).not('.non-responsive')) { makeTableFluid(this); } });