如何选择除了第一次出现的所有类别 [英] How to select all except the first occurence of a class
本文介绍了如何选择除了第一次出现的所有类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图选择除了第一个以外的类.action中的所有锚定标记,但似乎无法使用css过滤器。
$(。action:not(:first))。css(visibility,hidden);
没有效果
我也尝试每一个明确像这样
$(tr:contains('Second').action)。css(能见度,隐藏);
但这会使所有.action隐藏
解决!
$('。action:not(:first,:nth(2))')。css(能见度,隐藏);
解决方案
您的代码应该可以正常工作 您可能不得不调整您的选择器只有表格中的 .action
元素被选中。
您可以使用 .slice
[ docs] ,但如果您的选择器不起作用,则不会:
<$ c (1).css(visibility,hidden);
I'm trying to select the all anchor tags in a table that have the class .action except the first one but can't seem to do it using the css filters.
$(".action:not(:first)").css("visibility", "hidden");
Has no effect
I have also tried doing each one explicitly like such
$("tr:contains('Second') .action").css("visibility", "hidden");
but this makes all .action hidden
Solved!
$('.action:not(:first, :nth(2))').css("visibility", "hidden");
解决方案
You might have to adjust your selector so that only the .action
elements inside the table are selected.
You can use .slice
[docs], but if your selector does not work, this won't either:
$(".action").slice(1).css("visibility", "hidden");
这篇关于如何选择除了第一次出现的所有类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文