//show popup when clicking the trigger $('#trigger').on('click touch', function(){ $('#tooltip').show(); }); //hide it when clicking anywhere else except the popup and the trigger $(document).on('click touch', function(event) { if (!$(event.target).parents().addBack().is('#trigger')) { $('#tooltip').hide(); } }); // Stop propagation to prevent hiding "#tooltip" when clicking on it $('#tooltip').on('click touch', function(event) { event.stopPropagation(); });
Thank you so much. It worked for me
it’s working fine.
$(document).on(‘click touch’, function (e) {
if ($(event.target).hasClass(‘modal_wrapper’)) {
$(‘.modal’).fadeOut();
}
});
First, the “function (e) ” should be “function (event) “;
Second, this will hide your .modal, when .modal_wrapper is clicked, and I presume that .modal_wrapper is full screen width and height and that .modal is centred inside.
This will work in this particular case.
How about if instead of the modal, which has a wrapper that covers the entire screen so anything else in the page is basically un-clickable, you want to hide some sort of dropdown or tooltip?
Thanks for the comment.
Thanks. Its Working..