jQuery removeClass() doesn't work well?


#1

Hi!

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

Demo

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:

$(document).ready(function(){

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

Anyone has an idea why it doesn’t work?


#2

Try this

– oops. i guess this didnt work

Didn’t test it hehe!


#3

If I remove the Cufon, well it works then.

Strange.


#4

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.


#5

yeah I know, strange huh …


#6

It is working well :slight_smile: Try this:

		

And yes it is working :slight_smile:


#7

@peex yep, this works


#8

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:


#9

Yep, that works to!

Thanks :slight_smile: