Skip to content

Instantly share code, notes, and snippets.

@va9iff
Created February 3, 2023 00:29
Show Gist options
  • Save va9iff/ffdf07395498c3b03529b519d359766e to your computer and use it in GitHub Desktop.
Save va9iff/ffdf07395498c3b03529b519d359766e to your computer and use it in GitHub Desktop.
el("div.className.another") short function for creating elements with classes
export const el = str =>{
const strs = str.split('.')
let el = document.createElement(strs.shift())
for (let cls of strs) el.classList.add(cls)
return el
}
el('div.wrapper.hidden')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment