how come it cannot get ClassName correctly?
You have two functions assigned to the same method. Which one has the problem and what exactly are you trying to accomplish when a user hovers the mouse over the button?
Edit: You have a typo in the method name (in the second function assigned to the
onmouseover method. Also, the method you are trying to invoke on
document returns an array-like object of all the child elements with the class name specified. This means
element.classList.contains("blue") does not make sense. You will need to iterate through the list returned and check if the classList of each element contains the class “blue”.
Technically, you do not even need to check if the
blue class exists. You can simply remove it and if it did not have the class to begin with, then no harm done.