javascript - remove touch event on element - Stack Overflow

I have a DIV #overlay sitting over DIV #page, but on the #page div, theres a overscroll: auto on an ele

I have a DIV #overlay sitting over DIV #page, but on the #page div, theres a overscroll: auto on an element.

How can I disable all touch events on #page when #overlay is visible and then enable back once #overlay is hidden?

<div id="page">touchable content here</div>
<div id="overlay">sits on top of #page DIV</div>

This is for mobile webkit only.

I have a DIV #overlay sitting over DIV #page, but on the #page div, theres a overscroll: auto on an element.

How can I disable all touch events on #page when #overlay is visible and then enable back once #overlay is hidden?

<div id="page">touchable content here</div>
<div id="overlay">sits on top of #page DIV</div>

This is for mobile webkit only.

Share Improve this question edited Jan 19, 2012 at 5:11 calebo asked Jan 19, 2012 at 5:00 calebocalebo 3,44210 gold badges48 silver badges69 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

CSS Solution div#page { pointer-events: none; }


jQuery Solution

your touch event -

$('#page').click(function () {
    if($(this).hasClass('blockEvent')) return false;
    //do something...
});

when #overlay pops up -

// display #overlay
$('#page').addClass('blockEvent');

when #overlay closed -

// close #overlay
$('#page').removeClass('blockEvent');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745459618a4628645.html

相关推荐

  • javascript - remove touch event on element - Stack Overflow

    I have a DIV #overlay sitting over DIV #page, but on the #page div, theres a overscroll: auto on an ele

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信