我正在尝试不使用jQuery来使用JS。但到目前为止,这要难得多。
我正在尝试创建一个开关功能。
这是该函数:
function toggleDropdown(){
var dropdown = document.getElementById('games-dropdown')
if (dropdown.display = "none"){
dropdown.style.display = 'block';
} else {
dropdown.display = "none";
}
}
我在这里调用函数:
<li class="dropdown"><a onclick="toggleDropdown()">GAMES</a></li>
dropdown.classList.toggle("enabled")
- epascarello