Hide all divs (except the first) having the same class
I have 10 <div> with the same class
<div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> <div class="c1"></div> Now I need to hide all the <div> leaving it first.
+4
4 answers
Another way:
$('div.c1:gt(0)').hide (); Which is more flexible if you decide to keep 1st 2, for example.
Note that this is also 10% faster than other answers so far (in FF 5). See this performance test .
0