Bug Bounties

Detect outside click with only few lines of Javascript code

I found a pretty straight solution for this problem. You can add an event listener targeting an element by his id like so

        var pol = document.getElementById('pol');
        if(event.target != pol && event.target.parentNode != pol){
            pol.style.display = 'none';

⇐ Advent of code day one solutions Debouncing a search query in Vuejs ⇒