I am a newbie at jquery. I've been researching how to set cookies for a jquery function using the cookie plugin.
I have this simple hide and show function for a div but want the class states to persist after links to other pages and refreshing.
The JS looks like this
<script type="text/javascript">
$(document).ready(function(){
$("div.toggle_search").hide();
$("h2.trigger_up").click(function() {
$(this).toggleClass("active").prev().slideToggle(250);
if ($.cookie('more_search','1')) {
$("#criteria").attr('class', $.cookie('more_search'));
} else {
$("#criteria").attr('class', 'active');
}
$.cookie('more_search', $(".trigger_up").attr('class'));
return false;
});
});
</script>
HTML
<div id="criteria">
<div class="toggle_search">
<div class='left'>
Stuff goes here
</div>
</div>
<h2 class="trigger_up"><a href="#">See More Search Criteria</a></h2>
<div class="clear"></div>
</div>
Any help would be greatly appreciated. !