html - Long button press on iOS (Javascript) -


is possible make button able have long button press on ios? have searched on , not found solutions problem. @ first if long press button try select (for copying). using css, disabled this, still doesn't register long button press. think because possibility might scrolling page not long press in first place. purpose of want button disappear on long press.

here jsfiddle works on pc, doesn't on iphone (there div commented out because doesn't matter if long press on div or button, can create artificial button using div): http://jsfiddle.net/ynklmz5n/3/

thanks in advance.

var menutoggle = document.getelementsbyclassname("hide")[0]; menutoggle.style["-webkit-user-select"] = "none"; menutoggle.addeventlistener("mousedown", vanish); menutoggle.addeventlistener("mouseup", vanishclear); var timer; function vanish() {     longpress = false;     timer = settimeout(function() {         menutoggle.style.display = "none";     }, 1000); } function vanishclear() {     cleartimeout(timer); } 

have tried using touch events?

var timer  menutoggle.addeventlistener('touchstart', function() {   timer = settimeout(function() {     menutoggle.style.display = 'none'   }, 1000) }, false)  menutoggle.addeventlistener('touchend', function() {   cleartimeout(timer) }, false) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -