0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.