0
私は、クリックされたボタンの隣にあるテーブルを探しています。 すべてのテーブルとボタンが動的に作成されます。次のテーブルを見つける方法tbody jquery
<button type="button" onclick="addRows(this)">Add Row</button>
<table>
<tbody>
<td>A</td>
<td>A</td>
</tbody>
</table>
<button type="button" onclick="addRows(this)">Add Row</button>
<table>
<tbody>
<td>B</td>
<td>B</td>
</tbody>
</table>
<button type="button" onclick="addRows(this)">Add Row</button>
<table>
<tbody>
<td>C</td>
<td>C</td>
</tbody>
</table>
<button type="button" onclick="addRows(this)">Add Row</button>
<table>
<tbody>
<td>A</td>
<td>A</td>
</tbody>
</table>
私はこれを使用していますが、私はボタンの隣のテーブルを取得することができます:
$(this).closest("table").find("tbody");
'onclick =" addRows(this) "のようなインラインイベントハンドラを避ける" – j08691
はい、次はこのために使うことができます。 – Geeky