DEV Community

Discussion on: Matching elements with selectors in JS

Collapse
 
danielcss profile image
danielCSS

Just a nitpick:
The following line:

el.classList.has('foo') /* becomes */ el.matches('.foo');

I think you mean 'contains' instead of 'has'

  • Uncaught TypeError: elem.classList.has is not a function
Collapse
 
samthor profile image
Sam Thorogood

Oh yeah, I think I was thinking of Set or Map. I'll fix, thanks! 👍