loading...

re: Creating A Custom, Accessible Drop Down VIEW POST

FULL DISCUSSION
 

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 option?

Thanks,

 
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