How can I remove this popup when I'm outside?

http://jsfiddle.net/mnbayazit/by3zy/2/

I want the popup to disappear when I click somewhere in the background. The problem is that it disappears when I click the [X] button or popup.

Imagine being a calendar picker if that makes my intentions clearer.

How can I get this done?

+3
source share
2 answers
  • Install a handler clickso that the body removes your popup.

  • Set a handler clickfor the popup itself that triggers stopPropagation()in the event to prevent it from popping into the body.

Rough:

function showMyPopup(){
  ...
  $(myPopupDiv).click(function(e){
    e.stopPropagation();
  });
}
function closeMyPopup(){
  ...
}
$(document.body).click(closeMyPopup);
+7
source

jist , ( , z-index), "" click . , , , 100% ( ).

0

Source: https://habr.com/ru/post/1793756/


All Articles