Link to home
Start Free TrialLog in
Avatar of MFredin
MFredinFlag for United States of America

asked on

Changing current state on CSS tabs

Installed this menu... works perfectly.  

http://www.dynamicdrive.com/style/csslibrary/item/glossy_horizontal_menu/

Problem is, I'm not sure how to change the active tab (class="current") dynamically.  

I've tried the code below and it changes the active tab, but the 'menub_hover_left.gif' image seems to be layered underneath the 'menub_hover_right.gif' image.  It works fine on hover or if I manually change the class to .current.

Any help on how I can fix this?
The attached image shows HOME when I hover and SIGN UP as the active page body id="signup"
<-- Menu Code -->
<ul class="glossymenu">
	<li class="current"><a href="/"><b>Home</b></a></li>	
	<li id="t-signup"><a href="/SignUp"><b>Sign Up</b></a></li>	
	<li id="t-help"><a href="/Support"><b>Help</b></a></li>	
</ul>

<!-- Part of the CSS --->
.glossymenu li.current, .glossymenu li a:hover ,
body#home #t-home a,
body#signup #t-signup a,
body#help #t-help a

{
	color: #fff;
	background: url(../../Images/menu/menub_hover_left.gif) no-repeat left top; /*left tab image path*/
	background-position: left;
}

.glossymenu li.current a b, .glossymenu li a:hover b,
body#home #t-home a,
body#signup #t-signup a,
body#help #t-help a
{
	color: #fff;
	background: url(../../Images/menu/menub_hover_right.gif) no-repeat right top; /*right tab image path*/
}

Open in new window

menu.jpg
Avatar of Designbyonyx
Designbyonyx
Flag of United States of America image

The code you have posted is too incomplete to give advice on.  Can you please post a url, and we can help you fix this in a jiffy.

~Ryan
Try this (javascript):
$(document).ready(function() {
	//On Click Event
	$("ul.glossymenu li").click(function() {
		$("ul.glossymenu li").removeClass("current"); //Remove any "current" class
		$(this).addClass("current"); //Add "current" class to selected tab
		return false;
	});
});

Open in new window

Avatar of MFredin

ASKER

Hey Ryan,

Here's the URL:  http://tinyurl.com/254je52
ASKER CERTIFIED SOLUTION
Avatar of Zado
Zado
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MFredin

ASKER

Thanks Zado,

I updated with your code.  For some reason, the links do not work now.  The state does hold on the correct tabs when click them though.  But I think a CSS based solution is best.  What if my users dont have javascript enabled for whatever reason?
I can see it works (I used URL you provided), I think you need to use javascript, I don't think you can use css for this.
Sorry, didn't look at source code, but menu buttons work properly. Also this might help:
http://www.sohtanaka.com/web-design/examples/tabs/
You can find more examples, search 'jquery tabs' in google.
Avatar of MFredin

ASKER

Thanks Zado.  When I use the javascript code you provided, the links do not actually work... the tab class changes but I can not navigate from page to page.  

Thank you for the link.  I've looked at jquery tabs and others but the solution I have just plain looks better in my opinion, that's why I want to use it over jquery tabs.
I'm not sure you can do it without jquery, jquery tabs is the most popular way to do this.

Well, you can also create separate pages and mark proper tag with class=current in each page, but that's not what you want to do obviously.

However, I would recommend jquery tabs, but choice is yours.
Avatar of MFredin

ASKER

Is it possible to recreate this same look using jquery tabs?
Avatar of MFredin

ASKER

I've used jqueryui tabs before... the problem is, they don't have the look of the tabs on my page.  I'm after the style mainly.
Please grant the points and close the question, thanks :-)
To be clear here: I'm not asking for grant the points to me, but generally.
If you have a problem with any suggestion from experts or nothing works with your expectation, please let us know, so we will continue work on solution for you, thanks.