[英]Select first of multiple instances
I have 3 <section>
s on a page with the class .slider
and within these there are several <article>
s. 我在一个带有
.slider
类的页面上有3个<section>
,其中有几个<article>
。 For the purpose of making these work as tabbed content I want to use jQuery to hide all but the first of each these <article>
s. 为了使这些内容成为选项卡式内容,我想使用jQuery隐藏所有这些
<article>
第一个内容。
The following: 下列:
$(".slider > article:not(:first)").hide();
hides everything but the first <article>
in the first <section>
, I need it to iterate through the three <section>
s and hide the first in each of these. 在第一个
<section>
隐藏除第一个<article>
所有内容,我需要它遍历三个<section>
并在每一个中隐藏第一个。 I assume I need to use each()
to loop through them, but I can't make anything work. 我想我需要使用
each()
来遍历它们,但是我什么都做不了。
$(".slider > article:not(:first-child)").hide();
如果不是第一个孩子,则可以执行此操作。
$(".slider").find("article:not(:first)").hide();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.