re: Creating A Custom, Accessible Drop Down VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hello Emma, Great post indeed. Just wanted to know, how would you close the dropdown if we click outside of the dropdown without selecting any opt...
 
function _clickOutside() {
   document.addEventListener("click", function (event) {
     if (event.target.closest(".dropdown")) { //replace the class name to your needs
     return;
     }
     close(); //just calling a function that removes classList of isOpen
     }, false);
}

Hope this can help :)

code of conduct - report abuse