Created
November 19, 2024 11:37
-
-
Save upalexgill/b19c2fbf20c1ff275e3058d14ce3841a to your computer and use it in GitHub Desktop.
Remove CSS classes with prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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