javascript - jquery not adding class when using eq() -


having bit of trouble when using this:

$('.instrumentselect').click(function(){     var thiselement = $(this).index();     $('.instrumentselect').eq(thiselement).addclass('active');     $('.active').removeclass('active'); }); 

removes class fine, console logged var thiselement , returns correct index, not appending class it. fire bug not return error.

i'm not sure you're trying do, removing class first , adding later makes more sense. also, why using index , eq() when can add class $(this)?

try this:

$('.instrumentselect').click(function(){   $('.active').removeclass('active');   $(this).addclass('active');  }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -