I need to use javasript to close a dropdownmenu when click an link. I have a Dropdownmenu thats open with mouse:hover. Now i need a function that close the menu when click some link like "down1" from the menu. But i have no idea how to do.
.dropdown {
position: relative;
display: inline-block;
width: 25%;
}
.gap {
text-align: center;
padding: 1em 0em;
background-color: #f47721;
margin-top: 6%;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.16);
border-radius: 2%;
}
.dropbt1 {
background-color: #f47721;
color: white;
padding: 1px;
font-size: 13px;
border: none;
cursor: pointer;
}
.dropdown-content1 {
display: none;
position: absolute;
background-color: #f47721;
/* min-width: 160px; */
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.16);
z-index: 1;
}
.dropdown-content1 a {
color: white;
padding: 8px 3px;
text-decoration: none;
display: block;
}
.dropdown-content1 a:hover {
background-color: #d86a1e
}
.dropdown:hover .dropdown-content1 {
display: block;
width: 100%;
}
<div class="dropdown">
<div class="gap">
<h3>Dropdownmenu</h3>
<button class="dropbt1"><h3>please choose</h3></button>
<div class="dropdown-content1">
<a href="#" id="" class="specialLink">down1</a>
<a href="#" id="" class="specialLink">down2</a>
<a href="#" id="" class="specialLink">down3</a>
</div>
</div>
</div>
I need to use javasript to close a dropdownmenu when click an link. I have a Dropdownmenu thats open with mouse:hover. Now i need a function that close the menu when click some link like "down1" from the menu. But i have no idea how to do.