forked from debojyoti10CC/steadystridefinal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhome.js
49 lines (46 loc) · 1.86 KB
/
home.js
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
// document.getElementById('changeColorButton').addEventListener('click', function() {
// // Change the background color of the body
// const img = document.getElementById('changepic');
// img.src = "stablenew.jpg";
// document.getElementById('changeColorButton').style.display = 'none'
// document.getElementById('newchangeColorButton').style.display = 'block'
// document.getElementById('before').innerHTML = "After";
// });
const img = document.getElementById("newpictures");
const img1 = document.getElementById("newpic");
document
.getElementById("changeColorButton")
.addEventListener("click", function () {
img.style.display = "none";
img1.style.display = "block";
img.style.backgroundImage = "url(./stablenew.jpg)";
document.getElementById("changeColorButton").style.display = "none";
document.getElementById("newchangeColorButton").style.display = "block";
document.getElementById("before").innerHTML = "After";
});
document
.getElementById("newchangeColorButton")
.addEventListener("click", function () {
img.style.display = "block";
img1.style.display = "none";
document.getElementById("newpictures").style.backgroundImage =
"url(./watchl.png)";
document.getElementById("changeColorButton").style.display = "block";
document.getElementById("newchangeColorButton").style.display = "none";
document.getElementById("before").innerHTML = "Before";
});
let displayValues = document.querySelectorAll("#num");
let interval = 7000;
console.log(displayValues);
displayValues.forEach((displayValues) => {
let start = 0;
let end = parseInt(displayValues.getAttribute("data-val"));
let duration = Math.floor(interval / end);
let counter = setInterval(function () {
start += 1;
displayValues.textContent = start;
if (start == end) {
clearInterval(counter);
}
}, duration);
});