获取与id对应的表td输入值

时间:2014-10-17 07:40:26

标签: jquery webgrid

我需要更改所有td's的值,我怎样才能td下的所有DISReferralId

我有27 <tr class="alter-bgcolor"> <td class="grid_normal_column">42423</td> <td class="grid_normal_column">Etet Eryrytry</td> <td class="grid_normal_column">17/03/2014</td> <td class="grid_normal_column">No</td> <td class="grid_normal_column">No</td> <td class="grid_normal_column"></td> <td><input type="hidden" name="DISReferralId" id="27" value="27"></td> <td class="grid_normal_column">New</td> </tr> ...此ID如何过滤

代码:

{{1}}

1 个答案:

答案 0 :(得分:1)

获取输入元素:

  • 使用name属性:

    var elem = $('input[name="DISReferralId"]');
    
  • 使用value属性:

    var elem = $('input[value="27"]');
    
  • 同时使用namevalue属性:

    var elem = $('input[name="DISReferralId"][value="27"]');
    
  • 使用id属性:

    var elem = $('#27');
    // or
    var elem = $('input[id="27"]');
    

然后获取包含该输入的行的所有tds:

                 parent    parent
                   td       tr        all tds
                    |        |           |
                    \/       \/          \/
var alltds = elem.parent().parent().children()

// or

                 parent   all tds excepts
                   td     input parent td  add input parent td
                    |       |               |
                    \/      \/              \/
var alltds = elem.parent().siblings().addBack()