[jQuery] finding the state of slideToggle
I have a slideToggle functioning just fine on my page:
http://www.viktorwithak.com/Test/nav/
But I'm trying to get it to set a cookie that remembers what is closed
and what is open. So, step one, I'm trying determine (on click) what
the state of slideToggle is. Here is my code so far...
function initMenu() {
$('#groups ul').hide();
$('#groups li a').click(
function() {
$(this).next().slideToggle('normal');
var id = $(this).attr('id');
if ($(this).is(":hidden")) {
var state = "closed";
} else {
var state = "open";
}
alert(id + ' is ' + state);
return false;
}
);
}
...but everytime I click, I get the message "slide_toggle_# is open."
Can you please take a look at my if statement and let me know how to
determine the slide_toggle state? Once I get that working, I should be
able to figure out myself how to save the state for every ID to the
cookie. Thanks!