I am struggling with implementing JavaScript functionality on my website. Specifically, I have a dropdown menu in the hamburger menu that is causing some issues. Whenever I click on the services option, the dropdown opens but quickly closes again. I've tried using both jQuery and vanilla script to no avail. Additionally, when the hamburger menu is open, I want the "lorem" text to go under the dropdown menu instead of overlapping it. Any guidance on resolving these issues would be greatly appreciated. Thank you and have a wonderful day.
$(function () {
$(".hamburger-menu").on("click", function () {
if ($(".nav-list").hasClass("active")) {
$(".nav-list").removeClass("active");
} else {
$(".nav-list").addClass("active");
}
})
});
$(function () {
$(".dropdown-menu").on("click", function () {
if ($(".mini-menu").hasClass("active2")) {
$(".mini-menu").removeClass("active2");
} else {
$(".mini-menu").addClass("active2");
}
})
});
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
html {
font-family: 'Playfair Display', serif;
font-weight: 400;
}
:root {
--bg-color: #302b63;
--hover-color: #0f0c29;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: black;
}
/* Additional CSS styling omitted for brevity */
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="master.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<header id="top-bar">
<div class="container flex">
<h1 class="logo">Logo</h1>
<div class="hamburger-menu">
<span class="bars"></span></div>
<nav id="contain">
<ul class="nav-list">
<li class="item">
<a href="">Home</a>
</li>
<li class="item dropdown-menu">
<a href="">Services</a>
<ul class="mini-menu">
<li class="mini-item"><a href="">Front-End Developement</a></li>
<li class="mini-item"><a href="">Back-End Developement</a></li>
<li class="mini-item"><a href="">Full-Stack Developement</a></li>
<li class="mini-item"><a href="">WordPress Developement</a></li>
</ul>
</li>
<li class="item">
<a href="">Portfolio</a>
</li>
<li class="item">
<a href="">Articles</a>
</li>
<li class="item">
<a href="">Contact</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="lorem">Lorem ipsum dolor sit amet...
</div>
<script src="api.js"></script>
</body>
</html>