1
所以,我有几个表使用基于类的jQuery进行迭代,但是我的行为需要稍微改变,具体取决于我所处元素的ID。下面是我的代码:需要获得当前元素的ID
<table id="Brokers" class="nodeTable" border=1 />
<table id="Controllers" class="nodeTable" border=1 />
<table id="Cluster-Drivers" class="nodeTable" border=1 />
jQuery(".nodeTable").html(nodeHealthTable({
Role: jQuery(this).attr("id")
}))
这最终将使用空字符串填充角色。我如何访问当前元素的ID?
真棒,完美的工作,谢谢你! – Kreg 2013-02-08 23:36:48
@Kreg欢迎您。 – undefined 2013-02-08 23:39:17
@undefined不知道.html()也接受了一个函数,我将删除我的答案,因为我的答案中的.each()过于复杂。今天学到了新东西:D谢谢你! – thaJeztah 2013-02-08 23:39:31