我跟着HTML表:
Products | Pack Of | Quantity | Volume | Unit | Rebate Amount |
---|---|---|---|---|---|
现在我想得到第一行的id.在这种情况下的身份是reb1_1
.为了得到它我尝试下面的代码,但它没有工作.
$(document).ready(function() { $('.products').click(function () { var row = $(this).closest('table tbody:tr:first').attr('id'); alert(row); }); });
谢谢.