tags:

views:

87

answers:

1

Hi,

I have the following JQuery statement and it is adding the class 'current' but it is not removing the class form the siblings.

Any ideas why?

$('.page_link[longdesc=' + page_num + ']')
  .addClass('current').siblings('.current').removeClass('current');

Malcolm

+2  A: 

Without your HTML markup, I'm guessing your classes aren't direct siblings but wrapped in something (to give them a border maybe?) In that case, .siblings() isn't finding anything.

In any case, it might be simpler to just remove current from all class="page_link" elements without caring where they are, like this:

$(".page_link.current").removeClass('current');
$('.page_link[longdesc=' + page_num + ']').addClass('current');
Nick Craver