Home > Back-end >  Closing Dropdown Menu by Clicking Outside on page
Closing Dropdown Menu by Clicking Outside on page

Time:11-21

Hello i tried many times to do this but i give up can please help me

here is code i am newbie i cant figured it out.

HTML

<div id="navDemo"  style="margin-top:46px">
    
   
  <div id="myLinks">
      
  
  <a href="radio.php"  onclick="myFunction()">РАДИО</a>
  <a href="chat.php"  onclick="myFunction()">ЧАТ</a>
  
 
  
  </div>
 
  
</div>

JAVASCRIPT

function myFunction1() {
      var x = document.getElementById("myLinks");
      if (x.style.display === "block") {
       x.style.display = "none";
      } else {
        x.style.display = "block";
      }
    }
    
window.onclick = myFunction1;




CodePudding user response:

its done can close this qustion

CodePudding user response:

You might need to use the jQuery on() method. Here is the link. https://www.tutorialrepublic.com/codelab.php?topic=faq&file=jquery-close-dropdown-by-clicking-outside-of-them

  • Related