-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
51 lines (40 loc) · 1022 Bytes
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<title>
How to simulate a click
with JavaScript ?
</title>
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<b>
How to simulate a click
with JavaScript ?
</b>
<p>
The button was clicked
<span class="total-clicks"></span>
times
</p>
<button id="btn1" onclick="addClick()">
Click Me!
</button>
<script type="text/javascript">
let clicks = 0;
function addClick() {
clicks = clicks + 1;
document.querySelector('.total-clicks').textContent
= clicks;
}
// Simulate click function
function clickButton() {
document.querySelector('#btn1').click();
}
// Simulate a click every second
setInterval(clickButton, 1000);
</script>
</body>
</html>