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

后端 未结 5 1800
暖寄归人
暖寄归人 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:52

    It's much easier to do like this:

    if(!$('#foo').hasClass('bar')) { 
      ...
    }
    

    The ! in front of the criteria means false, works in most programming languages.

提交回复
热议问题