drop down menu created with only css, but need javascript to open and close using same link (.nav_item)

Viewed 23

on second click on nav_item, menu doesnot close but only closes when i click outside. i need to be able to close and open with only the nav_item with js.

   .menu_content{
    position: absolute;
    top:100px;
    opacity: 0;
    pointer-events: none;
    display: flex;
    }

   .menu_content:focus, .menu_content:focus-within{
    opacity: 1;
    pointer-events: visible;
    }

    .nav_item{
    display: -webkit-box;
    display: -ms-flexbox;
    -webkit-box-align: right;    
    -ms-flex-align: center;    
    align-items: center;    
    height: 76px;
    position: absolute;
    right: 0;
    top: 10px;
    font-weight: normal; 
    }
   .nav_item:focus + .menu_content, .nav_item:focus-within + .menu_content {
    opacity: 1;
    pointer-events: visible;
    }

0 Answers
Related