任何人都可以幫助我。我有一個表在其中一個單元格中包含嵌套表。我想追加「你好世界!」到外表的每一行中的第一個單元格(所以在下面的html中,我只想追加到單元格1a和2a)。我試過如下:JQuery - 直接子女的直接子女
$("div > table > tr > td:first-child").append(' Hello World!');
在下面的html:
<div class="divClass">
<table class="tableClass" border="1px">
<tr>
<td>1a</td>
<td>1b</td>
</tr>
<tr>
<td>2a</td>
<td>2b
<table border="1px"><tr><td>nested table cell</td></tr></table>
</td>
</tr>
</table>
</div>
,但它不工作。 ( - http://jsfiddle.net/NickyW/x3bqf/)
有什麼建議嗎?
感謝,
尼克
@Nick檢查並演示 – thecodeparadox
+1以追加到正確的單元格和工作演示。 – Nope
+1不錯的答案 - 我不會想到tbody :) – Dipak