Reputation: 5
Trying to change the property of specific div.. can anyone help me in this
<div class="photoHolder">
<img src="images/img1.jpg">
<div class="figCap">User description </div>
<h3>User Name</h3>
</div>
<div class="photoHolder">
<img src="images/img2.jpg">
<div class="figCap">User description </div>
<h3>User Name</h3>
</div>
Now if i click on any image... i want to change some properties the figCap of that image...
jQuery
$(".photoHolder img").click(function(event){
$(".figCap").slideToggle();
});
but it changes all the figCap.. i want that only which is associated to that pic only.. help me
Upvotes: 1
Views: 41
Reputation: 82241
use this
context with next selector to target desired div:
$(".photoHolder img").click(function(event){
$(this).next().slideToggle();
});
Upvotes: 1
Reputation: 59272
You need to use this
as a reference and use next
.
$(".photoHolder img").click(function(event){
$(this).next().slideToggle();
});
Upvotes: 0