使用javascript或jquery获取HTML表的最后一行rowid [英] Get the last row rowid of an HTML table using javascript or jquery
问题描述
您好我正在使用javascript动态添加和删除行,并且其工作正常...添加和删除行到HTML表。但是添加几行之后如果我删除表中的行然后添加一个新行..发生了不匹配..所以我想检索添加的最后一行的id ...我尝试了很多方法来egt HTML表格中最后一行的ID,但我无法得到..我尝试过的方法很少......如下:
$(''#tblrownew0 tr:last td:eq(1)'')。id
显示未定义。< br $>
$(''#tblrownew0 tr:last'')
这个如果我使用alert我正在获取objectobject但是我怎么能得到行的id?
请帮忙!!提前感谢你!!
(''#tblrownew0 tr:last td:eq(1)'')。id
显示未定义。
< blockquote>(''#tblrownew0 tr:last'')
如果我使用警报我会得到objectobject但是我怎么能得到行的ID?
请帮忙!!提前感谢你!!
只需使用 jQuery attr方法 [ ^ ]是这样的:
var id =
Hi i am adding and deleting rows dynamically using javascript and its working fine... the adding and deleting of rows to a HTML table. But after adding a few rows if i delete rows inbetween in the table and then add a new row.. there is a mismatch happening.. so i want to retrieve the id of the last row added... i tried many ways to egt id of the last row in the HTML table but i am not able to get.. few methods i tried were.... as follows:
$(''#tblrownew0 tr:last td:eq(1)'').id
it showed undefined.
$(''#tblrownew0 tr:last'')
this if i use alert i am getting objectobject but how can i get the id of the row??
Please help!! thanking u in advance!!
(''#tblrownew0 tr:last td:eq(1)'').id
it showed undefined.
(''#tblrownew0 tr:last'')
this if i use alert i am getting objectobject but how can i get the id of the row??
Please help!! thanking u in advance!!
Just use jQuery attr method[^] like this:
var id =
这篇关于使用javascript或jquery获取HTML表的最后一行rowid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!