Jquery:隐藏除第一个表之外的所有表的第一行
Jquery : Hide first row of all the tables except first table
我有很多表格,比如
<table class="mytable">
<tr class = "first_tr">
<td></td>
<td></td>
<td></td>
</tr>
<tr class = "second_tr">
<td></td>
<td></td>
<td></td>
</tr>
<tr class = "third_tr">
<td></td>
<td></td>
<td></td>
</tr>
</table>
<table class="mytable">
<tr class = "first_tr">
<td></td>
<td></td>
<td></td>
</tr>
<tr class = "second_tr">
<td></td>
<td></td>
<td></td>
</tr>
<tr class = "third_tr">
<td></td>
<td></td>
<td></td>
</tr>
</table>
我可能有 10 多个这样的表
我需要隐藏除第一个表之外的所有表的第一行(类名first_tr
)
试试这个:
$('td:nth-child(2):not(:first)').hide();
在这里演示
有关我使用的内容的更多信息:
- :第 n 个子项()
- :not()
- :第一
您可以使用.not()
方法排除第一个元素:
$('table.mytable').not(':first').find('.first_tr').hide();
你可以使用 .not() 选择器
$('.mytable').not(":eq(0)").find(".first_tr").hide()
或者,您可以使用 .gt() 选择器
$('.mytable:gt(0)').find(".first_tr").hide()
如果要隐藏第二行,请使用second_tr
而不是first_tr
您可以像
这样简单地实现这一点:
$('.first_tr', '.mytable').not(':first').hide();
演示 1
或者,在同一选择器中:
$('.first_tr', '.mytable:not(:first)').hide();
演示 2
相关文章:
- 而循环只设置php中输入字段中的第一个值
- 错误:$injector:modulerr模块错误(我的第一个SPA应用程序)
- IE11中的第二个调用取消了第一个Fetch API调用
- Javascript XMLHttpRequest——只有第一个POST请求有效
- 使用javascript或angularjs特定过滤器搜索字符串中第一个img标记的json值
- 将OnClick函数设置为<ul>,最后一个ul是擦除第一个ul-s
- RxJS油门行为;立即获取第一个值
- Angular UI网格:如何通过第一个UI网格中的按钮使第二个UI网格可见
- 选择多个实例中的第一个
- 如何在调用下一个请求之前完成第一个Ajax Get请求
- Lodash:返回对象的第一个键,该对象的值(即数组)中有一个给定的元素(即字符串)
- 看起来第一个console.log是'It’不太对
- 与杜兰达尔合作的第一个JavaScript项目.尝试从第三方 API 获取数据
- 节点发布错误对象的第一个“属性”
- Javascript:表单验证getElementById仅返回第一个id元素
- 仅将 CSS 规则应用于
中的第一个 ,而不分配类/ID - JS在隐藏未定义的值后仅从数组中返回第一个id的值
- 高图表,检测点是否在堆栈中的第一个
- 如何用纯JS瞄准每一行的第一个td
- jQuery可能放在同一行的第一个,也可能不是第一个