2011-10-03 72 views
4
$('.ui-widget-content').css('border','none'); 
    $('#helpDialog .ui-widget-content').addClass('HelpDialogBorder'); 

我這樣做是爲了移除邊框。但是,有一個元素我想保持邊界。選擇具有類別的元素,除了具有特定ID的一個元素

有沒有什麼辦法可以在第一行本身選擇所有具有類「ui-widget-content」的元素,但除了id爲「helpDialog」的元素?

回答

8

當然,使用:not()

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

試試這個(也看到我的jsfiddle):

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

你可以試試這個$('.ui-widget-content').not('#id')

相關問題