dolythgoe
asked on
jquery cookie help on selected tabs
Hi all,
I have a script which fades in content between tabs but I'm looking to add cookie code that I've successfully used elsewhere. I'm using the cookie jquery plugin:
http://plugins.jquery.com/project/Cookie
Here's my tab code: - looking to default to :first if nothing is set in the cookie or get the selected state from the cookie and display that first
I have a script which fades in content between tabs but I'm looking to add cookie code that I've successfully used elsewhere. I'm using the cookie jquery plugin:
http://plugins.jquery.com/project/Cookie
Here's my tab code: - looking to default to :first if nothing is set in the cookie or get the selected state from the cookie and display that first
//Load/Hide Tabs
$(document).ready(function() {
//When page loads...;
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
alert(this);
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content
return false;
});
});
ASKER
Thanks for that :)
Just trying to set the cookie in the onclick function too.
$.cookie('the_tab', value) <- How would I get the selected value (first, second, nth..) into this?
Thanks again for your help..
Just trying to set the cookie in the onclick function too.
$.cookie('the_tab', value) <- How would I get the selected value (first, second, nth..) into this?
Thanks again for your help..
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Awesome, thanks for your help! Works a treat.
Open in new window