jQuery单击后如何获取按钮上方的html表ID [英] jQuery how to get html table id above button after clicked
本文介绍了jQuery单击后如何获取按钮上方的html表ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个html表格,其后是一个在其下方显示添加行"的按钮.
I have an html table followed by a button that says "Add Row" below it.
当我单击按钮时,我想在html表上添加新行,但是首先我需要获取上面的html表ID.
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.
无论如何,jQuery中是否会说在此按钮前给我html表的ID"?
Is there anyway in jQuery to say "Give me the id of the html table right before this button"?
推荐答案
$("button").click(function(){
var tblID = $(this).prev("table:first").attr("id");
});
这篇关于jQuery单击后如何获取按钮上方的html表ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文