开发者

JQuery to removeClass of all links within an element

开发者 https://www.devze.com 2023-02-25 19:23 出处:网络
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'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

精彩评论

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