I had created a sample check boxes dropdown, I facing an issue in hiding the dropdown by clicking outside the dropdwon. Below is the code
var expanded = false;
function showCheckboxes() {
  var checkboxes = document.getElementById("checkboxes");
  if (!expanded) {
    checkboxes.style.display = "block";
    expanded = true;
  } else {
    checkboxes.style.display = "none";
    expanded = false;
  }
}
$('#checkboxes').click(function(e) {
  e.stopPropagation();
});
$(document).click(function() {
  $('#checkboxes').style.display = "none";
});.category {
  width: 250px;
}
#checkboxes {
  width: 250px;
  display: none;
  border: 1px #aaa solid;
  overflow-y: scroll;
  background-color: white;
}
#checkboxes label {
  display: block;
}
#checkboxes label:hover {
  background-color: #bbb;
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select class="category" onclick="showCheckboxes()">
  <option value="">Select cities
  </option>
</select>
<div id="checkboxes">
  <label> 
    <input type="checkbox" /> Bangalore
  </label>
  <label>  
    <input type="checkbox"  /> Hyderabad
  </label>
  <label>  
    <input type="checkbox" /> Delhi
  </label>
  <label>  
    <input type="checkbox" /> Mumbai
  </label>
  <label>  
    <input type="checkbox" /> Chennai
  </label>
  <label>  
    <input type="checkbox"  /> Panaji
  </label>
</div>I want the drop down to get close by clicking outside any where. kindly help me on this i tried the script to make the display style none, but its not working
 
     
     
    