How to add close button to dropdown menu that also reverts to menu button on another click

I am creating a custom dropdown menu for my WordPress blog header. I did everything correctly but could not add close button that opens on first click and revert to default on another click.

I mean when I click on menu button it open dropdown and show close button and on second click it close dropdown and show menu button again.

Please help, I just want to change class from “dropbtn” to “closebtn” on click and revert to “dropbtn” again on second click. With only javascript, no JQuery.

<label onclick=”myFunction()” class=”dropbtn”></label>

Read more here:: How to add close button to dropdown menu that also reverts to menu button on another click

Leave a Reply

Your email address will not be published. Required fields are marked *