简体   繁体   中英

touchstart event stops working after scroll

I have attached a touchstart event to my fixed positioned footer in a web-app

so the structure is like this:

<div id="content">i am a looong content.</div>
<div id="footer">i am tappable!</div>

and the code like this:

$("#footer").on('touchstart', function(e) { alert("tapped"); });

The problem is that when I scroll down the page to read the (long) content, the touchstart event for my footer just stops working! it does not get called anymore.

Does anyone have any idea why this might be happening? Thanks in advance.

May I suggest to use click instead, that way it will be call each time.

var idFooter = document.getElementById("footer");
idFooter.addEventListener("click", touched, false);

function touched(){
 alert("tapped");
}

Instead of user on did you try to use bind?

You may also use touchend to see it that way it work better.

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