Y
Y
Yuri Gets2018-02-21 13:25:17
JavaScript
Yuri Gets, 2018-02-21 13:25:17

How to close a modal window (Popup) on iOS by clicking on the background?

There is a code:

<script>
    $(document).mouseup(function (e) {
            var container = $("#popup1");
            if (container.has(e.target).length === 0){
                container.hide();
            }
        });
  </script>

It helps to close the modal window by clicking on an inactive (background) area that is not related to the modal window. This only works on Windows and Android, not on iOS. Please help or suggest your own.
ps source here (green buttons): https://yurii-hets.blogspot.com/#prices

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2018-02-21
@yora_gets

add cursor: pointer to .b-popup on mobile

N
Nikolai Shabalin, 2018-02-21
@nikolayshabalin

Try not mouseup, butclick

Z
zakharkang, 2018-02-21
@zakharkang

Hello. Try like this.

$(window).click(function (e) {
  var container = $("#popup1");
  if (!container.is(e.target) && container.has(e.target).length === 0) {
    container.hide();
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question