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

后端 未结 5 1772
暖寄归人
暖寄归人 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 01:51

    Use the not function instead:

    var lastOpenSite = $(this).siblings().not('.closedTab');
    

    hasClass only tests whether an element has a class, not will remove elements from the selected set matching the provided selector.

提交回复
热议问题