When I have this code, the ".active" function doesn't work when clicked. However, if I change the div class from "top-menu-popup" to "top-menu-popup active" when opening the page, the menu is already activated.
<div class="top-menu-popup">
<div class="top-menu-arrow" style="margin-right: 17.5px;"></div>
<div class="top-menu-item home" style="display: block;">Homepage</div>
<div class="context-menu-divider homepage" style="display: none;"></div>
<div class="top-menu-item contains-submenu">
"CARS"
<div class="top-submenu-popup">
<div class="top-menu-item volkswagen">Volkswagen</div>
<div class="top-menu-item mercedes">Mercedes</div>
<div class="top-menu-item ford">Ford Mustang</div>
<div class="top-menu-item ferrari">Ferrari</div>
<div class="top-menu-item dodge">Dodge</div>
<div class="top-menu-item lincoln">Lincoln</div>
<div class="top-menu-item jaguar">Jaguar</div>
</div>
</div>
</div>
.top-menu-popup {
min-width: 178px;
position: absolute;
background-color: white;
-webkit-border-bottom-left-radius: 7px;
-moz-border-radius-bottomleft: 7px;
border-bottom-left-radius: 7px;
border: 2px solid rgba(0, 0, 0, .3);
border-top: 0;
border-right: 0;
-webkit-background-clip: padding-box;
background-clip: padding-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 500;
padding: 5px 0;
min-height: 40px;
top: 50px;
right: 0;
display: none;
}
.top-menu-popup.active {
display: block;
}