に jQuery オブジェクトが含まれていthis
ます。
私が電話するとき:
console.log($(this).children("td.price.desired").html());
ターミナルは以下を出力します:
<h3 class="table-label"><span class="label label-default number"> 0 </span></h3>
<input name="trade_params[0][price_desired]" type="number" step="0.01" value="0" min="0.00" class="form-control number" placeholder="Chart Price">
<h3>
私の目的は、実際にタグ付きの要素を取得することです。
ただし、私が呼び出すと:
console.log($(this).children("td.price.desired h3").html());
結果は未定義だと言われました。
私の理解では、http: //api.jquery.com/descendant-selector/に記載されている先祖と子のセレクター メソッドを使用できます。
私は手に入れることができます<h3>
:
$(this).children("td.price.desired").children("h3")
最初の方法で何が間違っていますか? 私にとって、両方の方法は同等であると考えられています。
編集:
コンテキスト内の完全な HTML は次のとおりです。
<tr class="0">
<td class="price desired">
<h3 class="table-label"><span class="label label-default number"> 0 </span></h3>
<input name="trade_params[0][price_desired]" type="number" step="0.01" value="0" min="0.00" class="form-control number" placeholder="Chart Price">
</td>
</tr>