且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用javascript或jquery获取HTML表的最后一行rowid

更新时间:2023-01-12 16:07:43

(''#tblrownew0 tr:last td:eq(1)'')。id





显示未定义。



 


(''#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 =