At runtime, I have a loop that creates a number divwith the same class depending on the number in the database.
<div class="show">....</div>
<div class="show">....</div>
<div class="show">....</div>
I want to display this div using a function slideToggle()using jQuery. For each of them I have a separate hyperlink, which when clicked should display a div. There are also many tags between the hyperlink and the div that I want to switch.
<div>
<div>
<a href="#" class="display">View</a>
</div>
<br />
</div>
<div>
<div class="clear"></div>
</div>
<div class="show">....</div>
<div>
<div>
<a href="#" class="display">View</a>
</div>
<br />
</div>
<div>
<div class="clear"></div>
</div>
<div class="show">....</div>
<div>
<div>
<a href="#" class="display">View</a>
</div>
<br />
</div>
<div>
<div class="clear"></div>
</div>
<div class="show">....</div>
$(function () {
$(".display").click(function(){
$(".show").slideToggle();
return false;
});
});
Naturally, when it's called, each div layer is switched, no matter which hyperlink is clicked. I just want to switch the div closest to the given hyperlink.
Thanks in advance.
Barry source
share