Clayton Olson
Clayton Olson

Reputation: 3

Need to target item only inside div

Right now I have .clrChart hidden and want to unhide with click on .color but have multiple of these in a row so I need to target the one under the click.

<div class="color">
    <a><img src="img/clrBttn.png" alt="" /></a>
    <a href="#"><img src="img/clrChart2.jpg" alt="color chart" class="clrChart" /></a>
</div>

I have tried this w/ no avail.

$('.color').click(function() {
        $(this).next('.clrChart').show();
        }); 

any help would be greatly appreciated:)

Upvotes: 0

Views: 179

Answers (2)

TGH
TGH

Reputation: 39268

$('.color').click(function() {
   $(this).find('.clrChart').show();
}); 

This will find a descendant inside the current .color

Upvotes: 1

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324720

Use .find() instead of .next()

Upvotes: 1

Related Questions