关于jquery给表格td赋值的小问题

三日过后 2015-03-27 04:44:09
$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(1);

我这么写可以赋值上,能够在页面显示出来

但是按照下面这种 把1换成一个变量就不能显示了

注意alert出来是有值的


$.get(url,function(data){
sumPU=data.sumPUnit;
sumQU=data.sumQUnit;
sumPL=data.sumPLoad;
sumQL=data.sumQLoad;

$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(sumPU);
alert("pu:"+sumPU+"qu:"+sumQU+"pl:"+sumPL+"ql:"+sumQL);

});
...全文
2041 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2015-03-30
  • 打赏
  • 举报
回复
$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(sumPU+""); 这样不可以吗?
三日过后 2015-03-30
  • 打赏
  • 举报
回复
引用 7 楼 IUPRG 的回复:
...
var sumPU=data.sumPUnit;
...
$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(""+sumPU+""); //这么写


引用 11 楼 fxk1106 的回复:
html(“‘”+sumPU+“’”)像这样子


对 这样出来了 可能是数据格式的问题 但是页面显示的数据也加上了单引号
三日过后 2015-03-30
  • 打赏
  • 举报
回复
引用 6 楼 rui888 的回复:
$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']") .length 那么这个没找到吧。 你看上面是不是等于0
这个值是1
码代码的兔子 2015-03-28
  • 打赏
  • 举报
回复
html(“‘”+sumPU+“’”)像这样子
码代码的兔子 2015-03-28
  • 打赏
  • 举报
回复
给那个常量加个单引号
  • 打赏
  • 举报
回复
对了,你这个单元格是 jqgrid 的,那么是极有可能被所谓的“数据绑定”之类的脚本覆盖的! 一定要 debug 单步跟踪一下 这么只看结果没意义。
  • 打赏
  • 举报
回复
另外就是,你除了这个 $.get(url,function(data){ 回调赋值外, 还有其他脚本是给这个单元格赋值的么? 建议你 debug一下这个语句啊,也许它已经赋值了,然后紧跟着被你其他地方的 脚本 又重新给赋值了,也就是覆盖了!
  • 打赏
  • 举报
回复
... var sumPU=data.sumPUnit; ... $("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(""+sumPU+""); //这么写
tony4geek 2015-03-27
  • 打赏
  • 举报
回复
$("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']") .length 那么这个没找到吧。 你看上面是不是等于0
cscxxx 2015-03-27
  • 打赏
  • 举报
回复
试着直接带data.sumPUnit入html内容可能有助于侦错 $("#plsfList").find("tr[id="+rowIds[k]+"] td[aria-describedby='plsfList_sumPUnit']").html(data.sumPUnit);
三日过后 2015-03-27
  • 打赏
  • 举报
回复
引用 3 楼 rui888 的回复:
你这个没有数据吧。 alert("pu:"+sumPU+"qu:"+sumQU+"pl:"+sumPL+"ql:"+sumQL);
这个是有数据的 都是数字 类似1054.2
tony4geek 2015-03-27
  • 打赏
  • 举报
回复
你这个没有数据吧。 alert("pu:"+sumPU+"qu:"+sumQU+"pl:"+sumPL+"ql:"+sumQL);
三日过后 2015-03-27
  • 打赏
  • 举报
回复
引用 1 楼 u013762572 的回复:
你先html(function(n){ alert(n); return "看看这个元素的index存不存在啊"+n})
好像是没有 但是怎么直接给个值就能显示出来
microhex 2015-03-27
  • 打赏
  • 举报
回复
你先html(function(n){ alert(n); return "看看这个元素的index存不存在啊"+n})

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧