本文介绍了jQuery选择器-除第一个以外的所有选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个小的jQuery选择器问题,我有以下html:
I have a small jQuery selectors question, I have the following html:
<div class="member-info first"></div>
<div class="member-info"></div>
<div class="member-info"></div>
我想隐藏(使用jQuery)所有包含"member-info"类的div,但不隐藏那些包含"first"类的div,有什么想法吗?
I want to hide (using jQuery) all the divs that holds the "member-info" class, but not the one holding the "first" class, any thoughts?
推荐答案
$('.member-info:not(.first)').hide();
这使用> not-selector
排除具有first
类的元素.
This uses the not-selector
to exclude elements with the first
class.
或者,如果first
类的目的仅仅是识别第一个,则请执行以下操作:
Or if the purpose of the first
class is simply to identify the first, then do this instead:
$('.member-info').slice(1).hide();
这使用 slice()
方法返回从第二个匹配项开始的集合.
This uses the slice()
method to return a set starting with the second match.
这篇关于jQuery选择器-除第一个以外的所有选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!