Howdy folks,
My problem is that when a user clicks on the <h4>
it opens the hidden <div>
below it. That's great - works as expected. However when a user clicks back on the same <h4>
- it closes the <div>
and reopens it instantly.
I need the <div>
to stay closed. I also need the remaining functionality to stay in place.
This is my jQuery:
$(document).ready(function() {
$('div#winners-table div').hide();
$('div#winners-table h4').click(function(){
$('div#winners-table h4.open').each(function() {
$(this).attr('class', 'closed');
$(this).siblings('div').slideUp();
});
$(this).toggleClass('open');
$(this).siblings('div').slideToggle();
});
});
EDIT This is my HTML:
<div id="winners-table">
<h3>...</h3>
<ul>
<li>
<h4>...</h4>
<div>...</div>
</li><!-- ENDS -->
<li>
<h4>...</h4>
<div>...</div>
</li><!-- ENDS -->
<li>
<h4>...</h4>
<div>...</div>
</li><!-- ENDS -->
<li>
<h4>...</h4>
<div>...</div>
</li><!-- ENDS -->
</ul>
</div>