テーブルを含む 1 つの HTML ファイルを取得しました。
src.Html:
<table id="all">
<tr>
<th>Row 1</th>
<td>Content 1</td>
</tr>
<tr>
<th>Row 2</th>
<td>Content 2</td>
</tr>
<tr>
<th>Row 3</th>
<td>Content 3</td>
</tr>
</table>
そして、ここに私のコードがあります:
$('document').ready(function(){
var tempTable = $('<table id="tempTable"></table>');
tempTable.load('src.Html #all tr');
console.log(tempTable); --> it shows content of tempTable
console.log($(tempTable).find('tr')); --> it shows []
});
それは機能し、tempTable の内容を出力します。
しかし、ニーズに基づいて行を取得したい場合、何も表示されません! そのような:
$(tempTable).find('tr'); --> []
$(tempTable).find('tr').eq(1); --> []
$('#tempTable tr:eq(2)') --> []
誰でも理由を教えてもらえますか? その tempTable は通常の DOM オブジェクトではありませんか?