私はいくつかのテーブル行を循環しようとしています。jQuery each - (this)とクラス指定を組み合わせる
<table>
<tr id="ucf48">
<td class="ucf_text">
<input name="ucf_t48" value="Ann becomes very involved in the text she is reading." type="text">
</td>
</tr>
<tr id="ucf351">
<td class="ucf_text">
<input name="ucf_t351" value="Ann is a fast and confident reader." type="text">
</td>
</tr>
</table>
を私はサイクルにこのコードを使用しています:
$('#ucf tr').each(function(i,obj){
var cn=$(this).attr('id').substr(3);
var t=$(this +'.ucf_text input').val();
console.log("Row "+i);
console.log("Cnum: "+cn);
console.log(t);
});
コンソール出力は次のとおりです。
Row 0
Cnum: 48
Ann becomes very involved in the text she is reading.
Row 1
Cnum: 351
Ann becomes very involved in the text she is reading.
今私の炎誰かの前に、私が知っている次のように単純化された行があります私は '名前'を使って欲しいデータを参照することで、これを別の方法で行うことができます。しかし、なぜ私のcnum変数は 'this'に従っていますが、t変数はありませんか?
ありがとうございました。あなたが行うと
は、皆、ありがとうございました。私は今日いくつかの事を学びました:) – Nick