I've got my selectors wrong. I am trying to select all elements within a class that are links and remove a class from them. 开发者_开发知识库
I tried this to no avail.
$('.panel:a').removeClass('active');
Any ideas?
$('.panel a').removeClass('active');//Will remove class 'active' from all elements comes under elements that've class panel
$('.panel > a').removeClass('active'); // Will remove class only from immediate children
you can try this:
$('a.panel').removeClass('active');
//removes active from all anchor tags with class panel
You can do something like:
var objs = $('.panel');
$.each(objs, function(key, obj){
if(obj.is('a')){
obj.removeClass('active');
}
});
Does that help?
精彩评论