I'm using this jquery code to show and hide divs on my page. As you can see, I an limited to 5 divs. Is there a way to make them dynamic?
$(document).ready(function() {
$('.box').hide();
$('a.toggle').click(function() {
$('.box').toggle(400);
return false;
});
});
<a href="#" class="toggle" title="Show Comments"><img src="images/read.gif" alt="" /></a>
<div class="box" class="comment">hidden content</div>
This is my revised code
$(function () {
$('div.box').hide();
$('a.toggle').click(function () {
$(this).next('div.box').toggle(400);
});
});
<div class="entry">
<h3>Title</h3>
<p>content</p>
<p class="posted">Posted by Admin<br />
<a href="#" class="toggle">
<img src="read.gif" alt="" />
</a>
</div>
<div class="box" class="comment">Hidden</div>