Skip to content

Instantly share code, notes, and snippets.

@doeringp
Last active June 21, 2023 09:43
Show Gist options
  • Save doeringp/7798b37e248f9b0a3421c3dcc133c70f to your computer and use it in GitHub Desktop.
Save doeringp/7798b37e248f9b0a3421c3dcc133c70f to your computer and use it in GitHub Desktop.
Find a css class that is available on a web page
const findCssClass = (name) =>
Array.from(document.querySelectorAll("[class]"))
.flatMap(e => Array.from(e.classList))
.filter(s => s.indexOf(name) > -1)
findCssClass("text")
// => ['text-center', 'text-xl', '!text-sm', 'text-xl', 'text-center', 'text-center']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment