I'm using Popper.js to show a popup elment having the class .js-share-cf-popover
when clicking elements with class .js-share-cf-btn
.
But I want the popup to close only when I click outside of it. Here my actual code that show the popup:
var reference = $('.js-share-cf-btn');
var popover = $('.js-share-cf-popover');
popover.hide();
$(document).on('click', reference, function(e) {
e.preventDefault();
popover.show();
var popper = new Popper(reference, popover, {
placement: 'top',
});
});
I found something here but I can't get it works
Here My jsfiddle