When I click outside the dropdown menu then dropdown menu must close. How can I close the dropdown menu? Here is my code:
<div class="pull-right srch-box">
     <button onclick="search_function()" class="dropbtn"><i class="fa fa-search" aria-hidden="true"></i></button>
     <div id="myDropdown" class="dropdown-content">
          <form>
              <div class="input-group search-box form-group">
                 <input type="text" id="search" class="form-control" placeholder="Search here...">
                 <button type="button" class="btn btn-primary ">Search</i></button>
              </div>
          </form>
     </div>
</div>
js script for the open dropdown menu:
function search_function() {
    document.getElementById("myDropdown").classList.toggle("show");
}
 
What would be the js script to close the dropdown menu?