如何在 jquery 中排除多个 div

How to exclude more than one div in jquery

如何从此代码中排除更多的 div:

$(function() {
    $('a[href*="#"]:not([href="#about"])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html, body').animate({
              scrollTop: target.offset().top
            }, 1000);
            return false;
          }
        }
    });
});

您可以将项目添加为逗号分隔值,如 :not([href="#about"], [href="#home"])

但是还有其他方法,如下所示。

$('a[href*="#"]').not('[href="#about"],[href="#home"]');