removeClass jquery statement not working
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
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');
精彩评论