I have a div that looks like
<div class="draggable resizable abc table shadow"></div>
Clases are in no specific order. If I do $('div').attr('class') then I get a list of all the classes for that div. What I want is to only get classes that are not resizable, draggableor table. In this case i want abc shadow. How do I do this.
Note that you don’t need the second
replace(you don’t need to strip off leading and trailing whitespace) if all you want is a string that’s appropriate for setting theclassNameto.But then, if you’re trying to just remove a set of known classes from an element, far better to simply:
Alternative (without needing a regex):