How to make JavaScript work with 2 classid? There is a .dropbtn and I still have one .dropbtn1 class. I would like the menu to be shown here and there when pressed (with the same menu).

 /* When the user clicks on the button, toggle between hiding and showing the dropdown content */ function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); } // Close the dropdown menu if the user clicks outside of it window.onclick = function(event) { if (!event.target.matches('.dropbtn')) { var dropdowns = document.getElementsByClassName("dropdown-content"); var i; for (i = 0; i < dropdowns.length; i++) { var openDropdown = dropdowns[i]; if (openDropdown.classList.contains('show')) { openDropdown.classList.remove('show'); } } } } /* When the user clicks on the button, toggle between hiding and showing the dropdown content */ function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); } 
  • I don’t read it, but it seems like you just need to closest, but it’s not at all clear why you use two different classes, use one - zb '10
  • .classNameOne.classNameTwo ? - user207618
  • In my mobile version, the button looks different, and not at all in that <div> block, but I want my menu to open when I click it. - Topper-H

0