Jquery获取某行某列的值

function getRow(this) {
var row = $(this).parent("td").parent("tr"); //获取列表的row(行)
var value=$("#cellid",row).html(); //cellid是列名的ID
}


function onloadMessage()
{
$.ajax({
type:'post',
url:'ShowBook',
cache:false,
async:true,
success:function(transport)
{

var de=transport.documentElement;
var nodelist = de.getElementsByTagName("BookList");
var htmlstr="";

for (var i = 0; i < nodelist.length; i++) {

var bookid=nodelist[i].getElementsByTagName("bookid")[0].text;
var bookname=nodelist[i].getElementsByTagName("bookname")[0].text;
var author=nodelist[i].getElementsByTagName("author")[0].text;
var time=nodelist[i].getElementsByTagName("time")[0].text;
var price=nodelist[i].getElementsByTagName("price")[0].text;
htmlstr+="<tr>"
+"<td id='bookid'>"
+bookid
+"</td>"
+"<td>"
+bookname
+"</td>"
+"<td>"
+author
+"</td>"
+"<td>"
+time
+"</td>"
+"<td id='oldprice'>"
+price
+"</td>"
+"<td>"
htmlstr+="<input type='button' value='修改单价' id='edit' οnclick='editprice(this)'><td>"
htmlstr+="</tr>"

}
$("#bookList").html(htmlstr);
}
});
}


function editprice(obj)
{
var row=getRow(obj);
var oldprice=$("#oldprice",row).html();
var bookid=("#bookid",row).html();
$("#oldprice",row).html("<input type='text' id='newprice' size='7'>");
$("#newprice",row).blur(function(){
var newprice=$("#newprice",row).val();
if(newprice=="" || newprice==null)
{
newprice=oldprice;
}

if(isNaN(newprice)) //判断输入价格的格式是否正确
{
alert("请输入数字");
$("#newprice").focus(); //文本重新获取光标
$("#newprice").val("");
return false;
}
alert(newprice);
onloadMessage();
});
}


function getRow(obj)
{

var row=$(obj).parent("td").parent("tr");
return row;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值