我如何模拟按住单击按钮?我可以在哪里elements.[0].click();模拟点击,我怎样才能让它按住按钮例如 5 秒钟而不是放开它?
示例代码
<!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>
慕少森
跃然一笑
随时随地看视频慕课网APP
相关分类