I have this div:
<div onclick="funcao('')">
And on Iphone (mainly the 6) the onclick does not run very well. I saw the ideal is to use the ontouchstart , but when I put both of the error, it thinks it was clicked twice.
What to do?
I have this div:
<div onclick="funcao('')">
And on Iphone (mainly the 6) the onclick does not run very well. I saw the ideal is to use the ontouchstart , but when I put both of the error, it thinks it was clicked twice.
What to do?
What I usually do is like this:
var appEvents = {
down: 'ontouchstart' in window ? 'touchstart' : 'click' /* ou mousedown */,
move: 'ontouchmove' in window ? 'touchmove' : 'mousemove',
up: 'ontouchend' in window ? 'touchend' : 'mouseup'
// e outros que precises
}
and then use
el.addEventListener(appEvents.down, function(){
so it detects if it is in a browser environment and uses click
or mobile environment and uses touchstart