Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery删除元素中所有链接的类_Jquery_Class_Jquery Selectors - Fatal编程技术网

JQuery删除元素中所有链接的类

JQuery删除元素中所有链接的类,jquery,class,jquery-selectors,Jquery,Class,Jquery Selectors,我的选择器搞错了。我试图选择一个类中作为链接的所有元素,并从中删除一个类 我试过了,但没用 $('.panel:a').removeClass('active'); 有什么想法吗?你可以试试这个: $('.panel a').removeClass('active');//Will remove class 'active' from all elements comes under elements that've class panel $('.panel > a').removeC

我的选择器搞错了。我试图选择一个类中作为链接的所有元素,并从中删除一个类

我试过了,但没用

$('.panel:a').removeClass('active');
有什么想法吗?

你可以试试这个:

$('.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
$('a.panel').removeClass('active'); 
//removes active from all anchor tags with class panel
您可以尝试以下方法:

$('a.panel').removeClass('active'); 
//removes active from all anchor tags with class panel

您可以执行以下操作:

    var objs = $('.panel');

    $.each(objs, function(key, obj){
        if(obj.is('a')){
            obj.removeClass('active');
        }
    });

这有帮助吗?

您可以执行以下操作:

    var objs = $('.panel');

    $.each(objs, function(key, obj){
        if(obj.is('a')){
            obj.removeClass('active');
        }
    });
这有用吗