如何使用javascript在表的最后一行的第一列中获取值? [英] How to get the value within a table's last row's first column using javascript?

查看:100
本文介绍了如何使用javascript在表的最后一行的第一列中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实施向下滚动加载GridView 它似乎读取GridView在运行时生成的表格的最后一个tr的第一个td,以获取已加载的最后一个productid的值。问题是,当我试图在USerControl(这是一个嵌套的GridView)中实现该文章时,似乎我设置为LastProduct id的值是不正确的。我使用alert来查找LastProduct id的值,向下滚动,我得到了一个奇怪的长html类值。



I am trying to implement Load GridView on scroll down it seems to read the first td of last tr of the table generated by GridView on runtime to get the value of last productid which has been loaded. The problem is that when i tried to implement that article in a USerControl (which is a nested GridView) it seems value which i being set to LastProduct id is not correct. I used alert to findout the value of LastProduct id on scroll down and i got a weird lengthy html sort of value.

function BindNewData() 
{
           var lastProductId = $("#<%=GridViewUserScraps.ClientID %> tr:last").children("td:first").html();







GridView在开头有一个绑定列,它有id。理想情况下,LastProduct的值应该是一个数字(最后一行''第一列值)





运行时生成的HTML代码:



http://jsfiddle.net/LRSS2/1/




The GridView has a bound column at the begining which has id. So ideally the value of the LastProduct should be the a number ( last row'' first column value)


HTML code generated in runtime:

http://jsfiddle.net/LRSS2/1/

推荐答案

(#< span class =code-pagedirective><% = GridViewUserScraps.ClientID %> tr:last)。children(td:first ).html();
("#<%=GridViewUserScraps.ClientID %> tr:last").children("td:first").html();







GridView在开头有一个带有id的绑定列。理想情况下,LastProduct的值应该是一个数字(最后一行''第一列值)





运行时生成的HTML代码:



http://jsfiddle.net/LRSS2/1/




The GridView has a bound column at the begining which has id. So ideally the value of the LastProduct should be the a number ( last row'' first column value)


HTML code generated in runtime:

http://jsfiddle.net/LRSS2/1/


结帐链接下面

http://jsfiddle.net/LRSS2/ [ ^ ]



这里我创建了一个包含6行的html表,每行包含第一列不同的id值。

使用jQuery它会找到最后一行的第一个colunm值

Checkout below link
http://jsfiddle.net/LRSS2/[^]

Here i have created one html table with 6 rows, each row having first column with different id value.
Using jQuery it will find last row first colunm value


' #gridview1 tr:last')。find(' td:first')。html()
('#gridview1 tr:last').find('td:first').html()


这篇关于如何使用javascript在表的最后一行的第一列中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆