Still looking for that perfect solution for detecting clicking outside? Look no further! Introducing Clickout-Event, a package that provides universal support for clickout and other similar events, and it works in all scenarios: plain HTML onclickout
attributes, .addEventListener('clickout')
of vanilla JavaScript, .on('clickout')
of jQuery, v-on:clickout
directives of Vue.js, you name it. As long as a front-end framework internally uses addEventListener
to handle events, Clickout-Event works for it. Just add the script tag anywhere in your page, and it simply works like magic.
HTML attribute
<div onclickout="console.log('clickout detected')">...</div>
Vanilla JavaScript
document.getElementById('myId').addEventListener('clickout', myListener);
jQuery
$('#myId').on('clickout', myListener);
Vue.js
<div v-on:clickout="open=false">...</div>
Angular
<div (clickout)="close()">...</div>