-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path138.js
39 lines (36 loc) · 1.48 KB
/
138.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
const heading1 = document.querySelector(".heading1");
const heading2 = document.querySelector(".heading");
const heading3 = document.querySelector(".heading3");
const heading4 = document.querySelector(".heading4");
const heading5 = document.querySelector(".heading5");
const heading6 = document.querySelector(".heading6");
const heading7 = document.querySelector(".heading7");
const heading8 = document.querySelector(".heading8");
const heading9 = document.querySelector(".heading9");
const heading10 = document.querySelector(".heading10");
function changeText(element, text, color, time) {
return new Promise((resolve, reject) => {
setTimeout(()=>{
if(element){
element.textContent = text;
element.style.color = color;
resolve();
}else{
reject("element not found");
}
},time)
})
}
changeText(heading1, "one", "red", 1000)
.then(()=>changeText(heading2, "two", "purple", 1000))
.then(()=>changeText(heading3, "three", "green", 1000))
.then(()=>changeText(heading4, "four", "orange", 1000))
.then(()=>changeText(heading5, "four", "orange", 1000))
.then(()=>changeText(heading6, "four", "orange", 1000))
.then(()=>changeText(heading7, "four", "orange", 1000))
.then(()=>changeText(heading8, "four", "orange", 1000))
.then(()=>changeText(heading9, "four", "orange", 1000))
.then(()=>changeText(heading10, "four", "orange", 1000))
.catch((error)=>{
alert(error);
})