开发者

jQuery how to get html table id above button after clicked

开发者 https://www.devze.com 2022-12-17 03:36 出处:网络
I have an html table followed by a button that says \"Add Row\" below it. When I click on the button, I would like to add a new row onto the html table but first I need to get the html table id above

I have an html table followed by a button that says "Add Row" below it.

When I click on the button, I would like to add a new row onto the html table but first I need to get the html table id above.

Is there anyway in jQuery to say "Give me the id of the html table right before thi开发者_如何学Cs button"?


$("button").click(function(){
  var tblID = $(this).prev("table:first").attr("id");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消