Answers for "document click hide popup jquery"

0

document click hide popup jquery

//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();
});
Posted by: Guest on May-21-2021

Code answers related to "document click hide popup jquery"

Browse Popular Code Answers by Language