I need to set the width of a table based on a Javascript variable coming from a jQuery post.
$.post("get.php", {this: 'that'}, function(data){
var width = data // eg '300'
? set table width to 'width'
I'm new when it comes to jQuery, I know how to set the return into a div tag, but I'm guessing that won't help me in this instance.
First convert to numeric value using parseInt
then just set the width
property of the jQuery object:
var width = parseInt(data, 10);
$("#myTable").width(width);
"myTable" should be changed to the ID of the actual <table>
element.