9 Replies
document.documentElement
represents the html tagthis is what i have tried to list all the classes
but not working
works for me
though I'm not sure what you expect it to do, and your variable naming is a bit confusing
the classList you're grabbing isn't an element, and the values in the DOMTokenList it returns aren't elements
https://codepen.io/jochemm/pen/PoXZyjM?editors=1111
i have 2 class on html tag, i want to remove both
this 2 class on html tag
i could list it, but not able to loop and remove it
this would be a lot easier to talk about if you had code to share instead of screenshots, but what's probably happening is that you're removing elements, which is shifting the index of the remaining elements, or at least something similar.
If you want to remove all the elements you can do this
classList.remove
takes any number of arguments, and removes each from the classlist. the ...htmlClassList
takes the array-like DOMTokenList and spreads it out into individual arguments that get passed to remove
ok got it, thanks