我需要通过单击链接来过滤某个表格行。
function filterRows(statusName) {
$("#mainTable > tbody > tr").find(statusName).each( function () {
alert($(this));
//the alert is not shown
});
}
<a class="rejected" href="#" onclick="filterRows('rejected');">rejected</a>
<a class="new" href="#" onclick="filterRows('new');">new</a>
<table id="mainTable">
<thead>
<tr>
<td>col1</td>
<td>col2</td>
</tr>
</thead>
<tbody class="Content">
<tr class="rejected">
<td>data1</td>
<td>data12</td>
</tr>
<tr>
<td>data13</td>
<td>data15</td>
</tr>
<tr class="new">
<td>data16</td>
<td>data18</td>
</tr>
</tbody>
但它不工作,甚至alert($(this))
没有。有什么建议么?