[英]Onclick not toggled off when clicked
This toggle function works my drop down as I need to a point.当我需要一点时,这个切换功能可以让我的下拉菜单起作用。 when i clcik my link the menu opens with the overlay.
当我点击我的链接时,菜单会打开并显示覆盖层。 but if i click the link again only the menu closes.
但如果我再次单击该链接,则只有菜单关闭。 I need to change the overlay to none depending on toggle.
我需要根据切换将叠加层更改为无。
function navDeck() {
"use strict"
document.getElementById("myDropdown").classList.toggle("is-open");
document.getElementById("overlay").style.display = "block";
}
Did you try something like this.你有没有尝试过这样的事情。
New css class新的 css 类
.open-overlay{
display:block;
}
JS JS
function navDeck() {
"use strict"
document.getElementById("myDropdown").classList.toggle("is-open");
document.getElementById("overlay").classList.toggle("open-overlay");
}
I got it to work using the following我使用以下方法让它工作
function navDeck() {
"use strict"
document.getElementById("myDropdown").classList.toggle("is-open");
var e = document.getElementById("overlay");
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.