jQuery Toggle Cookie Support
Posted
by hell0w0rld
on Stack Overflow
See other posts from Stack Overflow
or by hell0w0rld
Published on 2009-12-30T20:18:46Z
Indexed on
2010/03/28
14:03 UTC
Read the original article
Hit count: 329
I'm trying to implement the jQuery Cookie plugin into my slide toggle script, but so far haven't been successful. Here's my code (without any cookie implementation):
jQuery:
$(document).ready(function() {
$('a.toggle').click(function() {
var id = $(this).attr('name');
$('#module' + id).slideToggle('fast');
$('a.toggle[name='+id+']').toggle();
return false;
});
});
HTML:
<a class="toggle" name="1" href="#">- Hide</a>
<a class="toggle hidden" name="1" href="#">+ Show</a>
<div id="module1"><p>Hello World</p></div>
Anyone know if it's easy enough to implement the jQuery Cookie plugin into my existing code so it remembers the open/closed state?
Thank you.
© Stack Overflow or respective owner