How would you modify this so that the popup disappears if you click anywhere outside the popup? I am using html5 and javascript within an epub3 document.
Possible duplicate of [How do I detect a click outside an element?](https://stackoverflow.com/questions/152975/how-do-i-detect-a-click-outside-an-element)
– Lars-Olof KreimJul 04 '18 at 07:49
1 Answers1
0
$('#trigger').bind('click touch', function(){
$('#tooltip').show();
});
$(document).bind('click touch', function(event) {
if (!$(event.target).parents().addBack().is('#trigger')) {
$('#tooltip').hide();
}
});
// Stop propagation to prevent hiding "#tooltip" when clicking on it
$('#tooltip').bind('click touch', function(event) {
event.stopPropagation();
});