'How to stop focusing after closing the button
I have a button in my navbar and when I press the button it opens a drop-down menu, so my question is how to stop focusing and the effects on my button when I press it again to close the dropdown menu?
Solution 1:[1]
let's say you want to make the background color of the button black, the code will be like this:
html:
<button id="dropDownMenu">click me</button>
css:
.active {
background-color: black;
}
javascript:
let dropDownMenuElement = document.querySelector("#dropDownMenu");
function toggleDropDownMenu() {
dropDownMenuElement.classList.toggle("active");
}
document.addEventListener("click", toggleDropDownMenu);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ht3aa |