问题
$('.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