Help with slider variable
Hello i am new to the forum and jquery,
I have been trying to make a div slider that only lets you have one div open at a time. I am halfway there i can get them to slide. The part when a div is open and you click to open another, the open div closes, this is the bit not working.If that makes sense!
first my html
-
<div id="events">
<div class="event">
<h2></h2>
<div class="eventinfo"><div>
<table>with all info which slides</table>
</div></div></div></div>
-
$(document).ready(function() {
$('div.event> div.eventinfo').hide();
$('div.event> h2').click(function() {
var $nextDiv = $(this).next('div.eventinfo');
var $visibleSiblings = $nextDiv.siblings('div:visible');
if ($visibleSiblings.length ) {
$visibleSiblings.slideUp('fast', function() {
$nextDiv.slideToggle('fast');
});
} else {
$nextDiv.slideToggle('fast');
}
});
});
i know its something to do with the variable sibling as the other divs are not direct siblings, can anybody help me?