Select elements with class except one with specific id

狂风中的少年 提交于 2019-12-19 09:18:09

问题


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

I am doing like this to remove border. But, there is an element where I want to keep border.

Is there any way in first line itself to select all elements with class "ui-widget-content" but except one with id "helpDialog"?


回答1:


Sure, use :not():

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



回答2:


Try this (also see my jsfiddle):

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



回答3:


You can try this $('.ui-widget-content').not('#id')



来源:https://stackoverflow.com/questions/7636275/select-elements-with-class-except-one-with-specific-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!