Click and Hold

HTML
<button>Click or Hold</button>
CSS
JAVASCRIPT
var button = document.querySelector('button'), timer; button.addEventListener("mousedown", function() { timer = setTimeout(function() { button.innerHTML = 'hold'; timer = null; }, 2000); // hold 2 second(s) }, false); button.addEventListener("mouseup", function() { if (timer) { button.innerHTML = 'click'; } clearTimeout(timer); }, false);
Expand for more options Login