Frontend Development

JavaScript Auto-Clicker(s)

Submitted by Yondu, , Thread ID: 197769

Thread Closed

RE: JavaScript Auto-Clicker(s)

AnubisCore
Newbie
Level:
1
Reputation:
0
Posts:
16
Likes:
0
Credits:
8
30-08-2021, 05:26 AM
#7
prefer get element by id, because is more faster than search by className (because using id you will return the first element with id, when code return the element, break the search; And searching by className you will return more than one element, that's very slow)

i prefer that

```js
const elementId = "clicker";
const button = document.getElementById(elementId);

const taskId = setInterval(() => button.click(), 0);

const cancelAutoClick = () => clearInterval(taskId);
```

Users browsing this thread: 1 Guest(s)