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