所以,我想使用带有“显示/隐藏左推菜单”按钮的菜单,该按钮正在工作,但由于某种原因,当我尝试删除其他按钮时,它停止工作?
我没有包含 CSS,因为我认为这不是问题,但如果需要,我可以包含指向 CSS 文件的链接。
HTML:
<body class="cbp-spmenu-push">
<nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
<h3>Menu</h3>
<a href="#">Celery seakale</a>
<a href="#">Dulse daikon</a>
<a href="#">Zucchini garlic</a>
<a
href="#">Catsear azuki bean</a> <a href="#">Dandelion bunya</a>
<a href="#">Rutabaga</a>
</nav>
<button id="showLeft">Show/Hide Left Slide Menu</button>
<button id="showRight">Show/Hide Right Slide Menu</button>
<button id="showTop">Show/Hide Top Slide Menu</button>
<button id="showBottom">Show/Hide Bottom Slide Menu</button>
<section class="buttonset">
<h2>Push Menus</h2>
<button id="showLeftPush">Show/Hide Left Push Menu</button>
<button id="showRightPush">Show/Hide Right Push Menu</button>
</section>
</body>
JS:
var menuLeft = document.getElementById('cbp-spmenu-s1'),
showLeftPush = document.getElementById('showLeftPush'),
body = document.body;
showLeft.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(menuLeft, 'cbp-spmenu-open');
disableOther('showLeft');
};
showRight.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(menuRight, 'cbp-spmenu-open');
disableOther('showRight');
};
showTop.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(menuTop, 'cbp-spmenu-open');
disableOther('showTop');
};
showBottom.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(menuBottom, 'cbp-spmenu-open');
disableOther('showBottom');
};
showLeftPush.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(body, 'cbp-spmenu-push-toright');
classie.toggle(menuLeft, 'cbp-spmenu-open');
disableOther('showLeftPush');
};
showRightPush.onclick = function () {
classie.toggle(this, 'active');
classie.toggle(body, 'cbp-spmenu-push-toleft');
classie.toggle(menuRight, 'cbp-spmenu-open');
disableOther('showRightPush');
};