我有一个表,其中所有行都是这样的:

<tr>
    <td class="name">name1</td>
    <td class="type">type1</td>
    <td class="edit">
        <a href="edit" class="edit">edit</a>
    </td>
</tr>


我需要禁用某些类型的edit href。
所以我需要这样的东西:

row = $('.mytable').find(row where .type value = type_with_no_edit) #this is where I need elp
row.find('a.edit').remove();


如果该行是第一行,那么我会这样做:

row = $('.mytable tbody>tr:first')


但并非总是如此。

最佳答案

您可以使用:contains伪选择器:

$('td.type:contains("type_with_no_edit")').siblings('.edit').empty();


演示:http://jsfiddle.net/XLwfs/

如果您不想清空TD,只需将锚定为目标并将其移除即可。

10-04 15:36
查看更多