I have 4 items which should be toggle-able. So when an item is visible, and I click on another item, the one I clicked should open. The other one should close.
Any suggestions on how I could do that?
I've tried to add this to my jQuery file, but nothing want to toggle then...
var sliderContent = $(this).next('.groupf-more');
$('.groupf-more').not(sliderContent).hide();
sliderContent.toggle();
Here is my jQuery:
jQuery(document).ready(function($) {
$('.groupf-more').hide();
$('.groupf-title').toggle(function() {
$(this).closest('li').find('.groupf-more').slideDown();
$(this, '.toggle-item').removeClass('groupf-title');
$(this, '.toggle-item').addClass('groupf-title-active');
return false;
},
function() {
$(this).closest('li').find('.groupf-more').slideUp();
$(this, '.toggle-item').removeClass('groupf-title-active');
$(this, '.toggle-item').addClass('groupf-title');
return false;
});
});
Here is my HTML:
<ul class="toggle" style="margin-right: 1%">
<li class="toggle-item">
<div class="groupf-title">Title</div>
<div class="groupf-more">Content</div>
</li>
<li class="toggle-item">
<div class="groupf-title">Title</div>
<div class="groupf-more">Content</div>
</li>
</ul>