开发者

JQuery to removeClass of all links within an element

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜