相关疑难解决方法(0)

每个jQuery - 将(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>
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码循环:

$('#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);
});
Run Code Online (Sandbox Code Playgroud)

控制台输出是:

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 …
Run Code Online (Sandbox Code Playgroud)

each jquery class this

4
推荐指数
1
解决办法
7468
查看次数

标签 统计

class ×1

each ×1

jquery ×1

this ×1