/    Sign up×
Community /Pin to ProfileBookmark

jquery and tabs help! Need to display clicked tab upon refresh

Hi all,

First off, thanks for this forum. I just found it and hope to build the community.

My problem is I tried using this tutorial to make tabs:
[url]http://apricotstudios.wordpress.com/2008/08/29/jquery-tabs-tutorial/[/url]

The problem is that when you refresh, it displays the first tab. If you were on any other tab and refreshed, then you have to click it again.

I did try to use jQuery Tabs, but I couldn’t figure out how to theme it myself without using theme roller.

Here is my implementation of it:

[CODE]<script type=”text/javascript”>
$(document).ready(function(){
$(‘#user_content .maintab’).hide(); // Hide all divs that are ‘hideable’
$(‘#user_content #top’).show();
$(‘#user_content div:first’).show(); // Show the first div
$(‘#user_content ul li:first’).addClass(‘first’); // Set the class of the first link to active

$(‘#user_content ul li a’).click(

function(){ // When any link is clicked
$(‘#user_content ul li’).removeClass(‘active’); // Remove active class from all links
$(‘#user_content ul li’).removeClass(‘first’);

//alert($(this).attr(‘href’));
if($(this).attr(‘href’)==’#user_profile_overview’){
$(this).parent().addClass(‘first’);
}
else{
$(this).parent().addClass(‘active’); // Set clicked link class to active
}

var currentTab = $(this).attr(‘href’); // Set variable currentTab to value of href attribute of clicked link

//alert(currentTab);

$(‘#user_content .maintab’).hide(); // Hide all divs that are ‘hideable’
$(‘#user_content #top’).show();
$(currentTab).show(); // Show div with id equal to variable currentTab

return false;
});
});
</script>
[/CODE]

Thanks so much in advance!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @vooboo13 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...