【问题标题】:Select elements with class except one with specific id选择具有类的元素,但具有特定 id 的元素除外
【发布时间】:2011-11-29 23:30:10
【问题描述】:
$('.ui-widget-content').css('border','none');
    $('#helpDialog .ui-widget-content').addClass('HelpDialogBorder');

我这样做是为了去除边框。但是,有一个元素我想保留边框。

有没有办法在第一行本身选择所有具有“ui-widget-content”类的元素,但ID为“helpDialog”的元素除外?

【问题讨论】:

    标签: jquery html css jquery-selectors


    【解决方案1】:

    当然,使用:not():

    $('.ui-widget-content:not(#helpDialog)').css('border', 0);
    

    【讨论】:

      【解决方案2】:

      试试这个(另见我的jsfiddle):

      $('.ui-widget-content').not('#helpDialog').css('border','none');
      

      【讨论】:

        【解决方案3】:

        你可以试试这个$('.ui-widget-content').not('#id')

        【讨论】:

          猜你喜欢
          • 2016-03-19
          • 1970-01-01
          • 2022-01-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-05-19
          • 1970-01-01
          相关资源
          最近更新 更多