Hello,
I'm trying to save the state of a slideToggle. Why is my var id giving a "undefined" error? Is there a simple way to do this action (save state of slideToggle)? (I'm a javascript / jQuery newbie).
- $("a#toggle").click(function(){
var id = $(this).next().attr('id');
$('#'+id).slideToggle('400',function(){
if ($(this).is(':hidden')) {
var state = "closed";
$.cookie('#'.id, state);
return false;
} else if ($(this).is(':visible')) {
var state = "open";
$.cookie('#'.id, state);
return false;
} else {
return false;
}
});
});
var show = $.cookie('#'.id);
if(show == 'closed'){
alert(show);
$(id).removeClass().addClass('hidden');
} else {
alert(show);
$(id).removeClass().addClass('container_toggle');
}
Thanks for your comments! :-)