i am working on implementing a menu button with HTML and JavaScript code
HERE IS THE HTML
MENU
<div class="mobilenav">
<li><a href="#">HOME</a></li>
<li><a href="#">SERVICES</a></li>
<li><a href="#">WORK</a></li>
<li><a href="#">TALK</a></li>
</div>
ICON
<a href="javascript:void(0)" class="icon">
<div class="MENU">
<div class="menui top-menu"></div>
<div class="menui mid-menu"></div>
<div class="menui bottom-menu"></div>
</div>
</a>
JS IMPLEMENTATION
$(document).ready(function () {
$(".icon").click(function () {
$(".mobilenav").fadeToggle(500);
$(".top-menu").toggleClass("top-animate");
$(".mid-menu").toggleClass("mid-animate");
$(".bottom-menu").toggleClass("bottom-animate");
});
});
I made changes to the ".icon" selector to improve behavior, but now whenever I click on other buttons like scroll down or contact, the menu opens. Is there a way to prevent this from happening?