0

I have a search bar whose display toggles if you click onto a search icon, like so:

searchIcon.addEventListener('click', () => {
  // toggle function that displays and hides search bar... 
});

For mobile, I would also like to listen for anytime a user touches outside the search bar DOM element and close it. Is there a way where an event listener can be attached to a DOM element, but listen for touches on anything other than that element?

dace
  • 5,819
  • 13
  • 44
  • 74

0 Answers0