classList not working as expected
var button = document.getElementById('dropdown-trigger'),
dropdownList = document.getElementsByClassName('dropdown-list'),
button.addEventListener('mouseover', displayDropdown);
function displayDropdown() {
dropdownList.classList.add('none');
}
I keep getting in the console:
Uncaught TypeError: Cannot read property 'add' of undefined
But if I were to use classList like:
function displayDropdown() {
button.classList.add('none');
}
It would work just fine. It seems like I can't use classlist on other elements?
dropdownList = document.getElementsByClassName('dropdown-list')is returning[],at the end instead of a;