1

Below is the code I am using. Clicking outside closes the lightbox in Windows and Android, but not in iPhone and iPad.

JS:

$(document).on('click', function(event) {
  if ($(event.target).has('.pop-up').length) {
    $('.pop-up-overlay').hide();
  }
});

HTML:

<div class="pop-up-overlay">
  <div class="pop-up">
    <p>Popup contents goes here.</p>
  </div>
</div>
Ramiz Wachtler
  • 5,623
  • 2
  • 28
  • 33
Rick
  • 57
  • 1
  • 2
  • 9

1 Answers1

2

Maybe try this for ios:

    $(document).on("click touchstart", function(event) {
      if ($(event.target).has('.pop-up').length) {
        $('.pop-up-overlay').hide();
      }
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pop-up-overlay">
  <div class="pop-up">
    <p>Popup contents goes here.</p>
  </div>
</div>

Similar question was asked in this link

Community
  • 1
  • 1
RegarBoy
  • 3,228
  • 1
  • 23
  • 44
  • Above code is not working on Safari(Mac) and Chrome(Mac). Will you please help me again? – Rick May 27 '16 at 11:26