Reputation: 1700
I want to hide all 2nd div inside another div
<div class="inner">
<div class="content"></div>
**<div class="content"></div>** // this show get hidden
</div>
<div class="inner">
<div class="content"></div>
**<div class="content"></div**> // this should get hidden
</div>
I have tried this:
$($('.inner').children()[12]).hide();
but it only hides one element,
Upvotes: 0
Views: 105
Reputation: 10619
$(".content").next().hide(); will do the Job.
OR
$(".inner").find(".content").eq(1).hide();
Upvotes: 0
Reputation: 6825
You can use the nth-child selector from jQuery to easily accomplish this.
$(".inner div:nth-child(2)").hide();
Upvotes: 0
Reputation:
If you want to do it without :nthchild selector:
$('.inner').each(function()
{
$(this).find('.content').eq(1).hide();
});
with :nthchild:
$(".inner div:nth-child(2)").hide();
Upvotes: 1