Is it possible to make a button be able to have a long button press on iOS? I have searched all over and not found any solutions for this problem. At first if you long press a button it will try to select it (for copying). Using some CSS, I disabled this, but it still doesn't register a long button press. I think it is because the possibility that you might be scrolling the page that it does not long press in the first place. The purpose of this is that I want the button to disappear on a long press.
Here is a JSFiddle that works on PC, but doesn't on my iPhone (there is a div commented out because it doesn't matter if the long press is on a div or button, I can create an artificial button using a 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);
}