Reputation: 12864
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
Upvotes: 0
Views: 2787
Reputation: 630379
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');
Upvotes: 3