我正在构建一个使用JavaScript的移动页面,使顶级菜单下拉和关闭,但它无法正常工作.这是JS
<script>
window.onload = function () {
var elem = document.getElementById('navBarMobile');
var burger = document.getElementById('hamburgerMobile');
var cross = document.getElementById('crossMobile');
}
function menuExpand() {
elem.style.transition = "height 1s linear 0s";
elem.style.height = "292px";
burger.style.transition = "opacity 0.5s linear 0s";
burger.style.opacity = "0";
burger.style.zIndex = "0";
cross.style.transition = "opacity 0.5s linear 0.5s"
cross.style.opacity = "1";
cross.style.zIndex = "1";
}
function menuClose() {
elem.style.transition = "height 1s linear 0s";
elem.style.height = "87px";
burger.style.transition = "opacity 0.5s linear 0.5s";
burger.style.opacity = "1";
burger.style.zIndex = …Run Code Online (Sandbox Code Playgroud)