'How to simulate a hold click on a button class
How can i simulate a hold click down onto a button?
where i can use elements.[0].click(); to simulate a click, how can I make it so that it would hold down the button for e.g 5 seconds instead of just letting it go?
sample code
<!DOCTYPE html>
<html>
<body>
<button class="button" id="button">You released the mouse button.</p>
<script>
document.getElementById("button").onmousedown = function() {mouseDown()};
document.getElementById("button").onmouseup = function() {mouseUp()};
function mouseDown() {
document.getElementById("button").innerHTML = "The mouse button is held down.";
}
function mouseUp() {
document.getElementById("button").innerHTML = "You released the mouse button.";
}
</script>
</body>
</html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
