如何清空所有td:eq(2)而不循环遍历jquery中的所有行 [英] How to empty all td:eq(2) without loop through all row in jquery
本文介绍了如何清空所有td:eq(2)而不循环遍历jquery中的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<table class="@listitems.tablename">
<thead>
<tr>
<th id="gradeName">@item.GroupLabel</th>
<th id="selectCategory" class="grade_td">Select One</th>
<th id="Comments">Comments</th>
</tr>
</thead>
<tbody>
<td>text</td>
<td><input type="radio" name="@items.ControlId" checked="@listItems.IsChecked" class="UnCheckOthers" id="@items.ControlId" value="@listItems.ControlValue"/>
@listItems.ControlValue</td>
<td class="Comments">comment</td>
</tbody></table>
<br />
This is my table structure. Now i want to clear all the td:eq(2) from the above table when i click, any of the radiobuttons inside the table. I have written jquery code to do this task that works fine, for first row of the table how can i empty all the td inside this table using jquery.<br />
$('.UnCheckOthers').click(function () {
var className = $(this).closest('table').find('th:eq(0)').text();
$('.' + className.replace(/\s+/g, '').toLowerCase() + ' td:eq(2)').empty();
});
Can anyone give solution to this problem?
推荐答案
(' .UnCheckOthers')。点击( function (){
var className =
('.UnCheckOthers').click(function () { var className =
( this )。nearest(' table')。find(' th:eq(0 )')。text();
(this).closest('table').find('th:eq(0)').text();
(' 。 ' + className.replace(/ \s + / g,' ')。toLowerCase ()+ ' td:eq(2)')。empty();
} );
('.' + className.replace(/\s+/g, '').toLowerCase() + ' td:eq(2)').empty(); });
Can anyone give solution to this problem?
这篇关于如何清空所有td:eq(2)而不循环遍历jquery中的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文