How to use in jQuery :not and hasClass() to get a specific element without a class

后端 未结 5 1774
暖寄归人
暖寄归人 2021-01-31 01:08

I have this line of code:

$(\'#sitesAccordion .groupOfSites\').click(function() {
    var lastOpenSite = $(this).siblings().hasClass(\':not(.closedTab)\');
    c         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 02:00

    jQuery's hasClass() method returns a boolean (true/false) and not an element. Also, the parameter to be given to it is a class name and not a selector as such.

    For ex: x.hasClass('error');

提交回复
热议问题