forked from HuXn-WebDev/HTML-CSS-JavaScript-100-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (16 loc) · 560 Bytes
/
app.js
File metadata and controls
21 lines (16 loc) · 560 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const followers = document.querySelectorAll(".followers");
followers.forEach((followersCounter) => {
followersCounter.innerHTML = "0";
const updateFollowersCounter = () => {
const target = +followersCounter.getAttribute("data-target");
const c = +followersCounter.innerText;
const increment = target / 500;
if (c < target) {
followersCounter.innerHTML = `${Math.ceil(c + increment)}`;
setTimeout(updateFollowersCounter, 1);
} else {
followersCounter.innerText = target;
}
};
updateFollowersCounter();
});