e: Modified answer.
Hello,
Check this, it will dynamically (ish) set the table width
http://jsfiddle.net/joshuamartin/KtAny/
(function() { var tdWidth = '300'; var columnCount = $("#tID").find('tr')[0].cells.length; var tableWidth = tdWidth * columnCount; $("table#tID").attr('width', tableWidth);
You need to manually enter the width of your td, because I cannot figure out how you can get the CSS style from the stylesheet.
Something like this might help you if you want everything to be dynamic, but this solution seems to work well. I broke it pretty much, but you could do it all on one line with the variable tdWidth.
(function() { var tdWidth = '300'; $("table#tID").attr('width', $("#tID").find('tr')[0].cells.length * tdWidth); })();
Joshua M Mar 16 '12 at 9:59 2012-03-16 09:59
source share