mheonyae
mheonyae

Reputation: 643

Find all div id's except one and remove class

I want to remove classes from div's that have a ID that start and end with same pattern.

$('[id^="mystr"][id$="_mynd"] #ednv').removeClass('vision');

this works for all divs on my site, but i would like to exclude one specific div at path #mystr645_mynd > #ednv i dont want this specific div's to be affected?

Upvotes: 1

Views: 160

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115212

Use :not() pseudo-class selector. Although you should use class instead of id for a group of elements since id should be unique and only get selected the first.

$('[id^="mystr"][id$="_mynd"]:not(#mystr645_mynd) .ednv').removeClass('vision'); 
//----------------------------^^^^---------------^^^---------

Upvotes: 5

Related Questions