jQuery post返回变量
我需要根据来自jQuery帖子的Javascript变量设置表的宽度jQuery post返回变量,jquery,post,Jquery,Post,我需要根据来自jQuery帖子的Javascript变量设置表的宽度 $.post("get.php", {this: 'that'}, function(data){ var width = data // eg '300' ? set table width to 'width' 对于jQuery,我是新手,我知道如何将return设置为div标记,但我猜这对我来说没有帮助。首先使用parseInt转换为数值,然后只设置jQuery对象的width属性: var width = par
$.post("get.php", {this: 'that'}, function(data){
var width = data // eg '300'
? set table width to 'width'
对于jQuery,我是新手,我知道如何将return设置为div标记,但我猜这对我来说没有帮助。首先使用
parseInt
转换为数值,然后只设置jQuery对象的width
属性:
var width = parseInt(data, 10);
$("#myTable").width(width);
“myTable”应该更改为实际
元素的ID。正如影子向导所说,这里是jquery文档页面