简体   繁体   中英

Popup 'close' button doesn't work on iPhone

I'm not sure why but the popup (which only shows once per session) has a close button (X) which doesn't work on an iPhone. However, it works fine on desktop. Below is the code I am using. Is there anything I can do to make this work?

Here is the site .

if (sessionStorage.getItem('popState') != 'shown'){
    $("#popup-wrap").delay(2000).fadeIn();
    sessionStorage.setItem('popState','shown')
}

$('body').on('click touch', '#popup-close', function() {
    $('#popup-wrap').fadeOut();
});

In my experience, iPhone has trouble with the jQuery.on event. Try binding a function to the pop-up element eg:

<script type="text/javascript">
    function closePopup() {
        $('#popup-wrap').fadeOut();
    }
</script>

<div id="popup-wrap">
    <span onclick="closePopup()">X</span>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM