我需要更改所有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}}
答案 0 :(得分:1)
获取输入元素:
使用name
属性:
var elem = $('input[name="DISReferralId"]');
使用value
属性:
var elem = $('input[value="27"]');
同时使用name
和value
属性:
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()