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
Post a Comment