Skip to content

Instantly share code, notes, and snippets.

@upalexgill
Created November 19, 2024 11:37
Show Gist options
  • Save upalexgill/b19c2fbf20c1ff275e3058d14ce3841a to your computer and use it in GitHub Desktop.
Save upalexgill/b19c2fbf20c1ff275e3058d14ce3841a to your computer and use it in GitHub Desktop.
Remove CSS classes with prefix
const prefix = "is-";
const elements = document.querySelectorAll(<SELECTOR>);
elements?.forEach((element) => {
const classes = elements.className
.split(" ")
.filter((c) => !c.startsWith(prefix));
elements.className = classes.join(" ").trim();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment