Answer the question
In order to leave comments, you need to log in
How is a click outside of an element tracked?
For example, there is a dropdown , which has a dropdown list when you click on it.
How to track a click outside of this element to close it?
Answer the question
In order to leave comments, you need to log in
Track the click on the document, and if event.target is not the desired element, then execute the closing code.
UPD: Example https://codepen.io/VladIT4/pen/vjNOKW
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question