I'm currently working on a project where I have implemented a button that displays a menu when clicked. I am attempting to change the color of the button when it is active, however, the toggleClass function is not behaving as expected. Below is the code snippet that I am using.
$(".services-btn").click(function() {
$(this).toggleClass("active-btn");
});
div.services-btn {
background-color: black;
color: #f9f9f9;
cursor: pointer;
float: left;
margin: 10px;
padding: 15px 0;
text-align: center;
width: 80px;
}
.active-btn {
background-color: darkred;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="services-btn mobile">Services</div>