jQuery"OR”;具有共享修饰符的选择器

jQuery "OR" selector with shared modifiers?

本文关键字:共享 选择器 quot OR jQuery      更新时间:2023-09-26

例如,有较短的方法吗

$("td:nth-child(2),th:nth-child(2)").hide()

我试过$("td,th").hide(":nth-child(2)"),但不起作用。有人对此有想法吗?谢谢

使用.filter()

$("td,th").filter(":nth-child(2)").hide();

.过滤器(选择器)

描述:将匹配的元素集减少到与选择器匹配或通过函数测试的元素集。