jQuery removeClass() doesn't work well?



Yeah I know I’m back again with another jquery issue :D.


I’m almost done with coding this template but I’m having some problems with the following:

  • There is a class called 'active' that is added to the first anchor in navigation, this is done with jQuery, so far so good.
  • When you click on another link the jQuery should give the clicked link the class 'active' and remove it from the 'previous' link.

All of this works just fine, but the class ‘active’ isn’t removed from the previous link.

Here’s my jQuery code:


	$('.nav a:first').addClass("active");
	$('.nav a').click(function(){
		$('.nav a').removeClass("active");
		return false;

Anyone has an idea why it doesn’t work?


Try this

– oops. i guess this didnt work

Didn’t test it hehe!


If I remove the Cufon, well it works then.



mmm thats weird. maybe it’s because cufon renders the font only once. i don’t know.

You know whats also weird, when you click the new anchor, it gets blue, when you hover the old one, and than take the mouse out it gets white.


yeah I know, strange huh …


It is working well :slight_smile: Try this:


And yes it is working :slight_smile:


@peex yep, this works


Hey, didn’t tested that yet, but I tested this:

$('.nav a').click(function(){
		Cufon.set('color', '#f9f9f9').replace(".nav a");
		Cufon.set('color', '#038dbe').replace($(this));

and it works to :slight_smile:


Yep, that works to!

Thanks :slight_smile: