myTest.onclick = function() { var subDrop = document.getElementsByClassName('sub_main'); alert(subDrop); subDrop.style.display = 'none'; }