标题说的就是这一切。该功能可以工作1次,当我在菜单外单击时它会关闭,但是当我在菜单外单击后,菜单<div class="topnav" id="myTopnav">
<a href="slotenvervangen" class="active">Slotenvervangen</a>
<a class="menulink" href="index"><span>Home</span></a>
<a class="menulink" href="slotenopenen"><span>Sloten openen</span></a>
<a class="menulink" href="inbraakbeveiliging"><span>Inbraakbeveiliging</span></a>
<a class="menulink" href="contact"><span>Contact</span></a>
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a>
</div>
$(document).click(function(){
$(".menulink").hide();
});
/* tried one,two then ended up trying to use them all*/
$(".topnav,.icon,.menulink").click(function(e){
e.stopPropagation();
});
function myFunction() {
var x = document.getElementById("myTopnav");
if(x.className === "topnav"){
x.className += " responsive";
}else{
x.className = "topnav";
}
}
不再打开。有人可以帮我解决这个问题吗?谢谢你的时间
{{1}}
答案 0 :(得分:0)
您需要在隐藏时点击选项时显示menulink
,
所以添加代码以在menulink
,
myFunction
function myFunction() {
$(".menulink").show();
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}