海海日记-冯海滨博客

您现在的位置是:首页 > C# > 正文

C#

jquery获取表格中选中行的第一个单元格的值

happyfhb2012-10-17C#2957

来自百度知道 感谢这位仁兄

//获取选中行的ID function getSelectRowFindID(obj) {

//this就是触发动作的元素本身,触发函数时传this,getSelectRowFindID(this)

//向上一级【parent()】是td,再向上【parent()】是tr ,找到tr的隐藏域或者是单元格绑定的

ID var ID= $(obj).parent().parent().find("input:hidden").val();

//隐藏域

ID=$(obj).parent().parent().children().eq(0).text(); //单元格:tr的子元素【children()】的第一个td【eq(0)】的文本值。

}

自己改进的代码

function getRow(obj) {
            //this就是触发动作的元素本身,触发函数时传this,getSelectRowFindID(this)
            //向上一级【parent()】是td,再向上【parent()】是tr ,找到tr的隐藏域或者是单元格绑定的ID
            alert($(obj).children().eq(0).html());
            alert($(obj).children().eq(1).html());
            alert($(obj).children().eq(2).html());
        }

平淡中储蓄成长

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~