Reputation:
I have two parent div with it's corresponding child div's. I want to modify something in my second div's child div but it has no id.How will I do that without affecting the first parent div's child div?
<div class="main">
<div id="loggedin" class="container-fluid">
</div>
</div>
<div class="main">
<div class="container-fluid">
</div>
</div>
Upvotes: 2
Views: 143
Reputation: 9637
try
$(".main:eq(1) .container-fluid");
or
$(".main:eq(1)").find(".container-fluid");
Upvotes: 2
Reputation: 790
Here is what you need of
$('.main').eq(1).children('div').text()
check this fiddle
For more DOM traversals go through this link
Upvotes: 0
Reputation: 12213
And a pure javascript solution:
var elems=document.getElementsByClassName("container-fluid");
var item=elems[1];
Upvotes: 0
Reputation: 82231
You can use .eq()
selector here:
$('.main .container-fluid:eq(1)');
or :not
selector:
$('.main .container-fluid:not(#loggedin)');
Upvotes: 0