I've been trying to use classList as described in the documentation here:
https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
However, I keep getting errors in the browser saying 'contains' or 'add' is undefined. I don't understand why.
I've used:
for (i = 0; i < card.length; i++) {
card[i].addEventListener('click', function () {
this.classList.toggle('open');
this.classList.toggle('show');
});
And classList works great!!. However, when I write:
let flipped = document.classList.contains('open');
I get the error "contains" is undefined.
If anybody can explain to me how these uses of classList are different I would be incredibly thankful!!
Side Note: I'm using pure javascript and troubleshooting in chrome