javascript - Jquery:从单元格值获取行

标签 javascript jquery html-table row

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

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

我需要禁用某些类型的编辑 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')

但情况并非总是如此。

最佳答案

听起来像是过滤器的工作......

$('.mytable tr').filter(function() {
    return $("td.type", this).text() === "type_with_no_edit";
}).find('a.edit').remove();

这会找到类类型的 td 中包含文本 type_with_no_edit 的每一行,并删除同级的带有 a.edit 的 td。

关于javascript - Jquery:从单元格值获取行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529433/

相关文章:

javascript - 如何更新 cookie 值(而不更改过期日期)? javascript

jquery - 更改单击的表格行的背景颜色

HTML & CSS : Can't center my tables

php - php while循环中的动态rowspan

javascript - asp.net 中的 HTML 标记注入(inject)

javascript - 根据选择框中的选项值显示/隐藏字段

javascript - 从以特定单词开始直到结束的字符串中提取单词

javascript - 使用 JQuery 全局访问具有相同类名的元素

javascript - jQuery dragenter 或 dragover 以包含子项

javascript - 删除html表格中的空行