- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
22 lines (18 loc) · 675 Bytes
/
Copy pathscript.js
File metadata and controls
22 lines (18 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
constworker=newWorker("worker.js");
constshowResultOfWorker=document.getElementById("show-worker-result");
consttotalButton=document.getElementById("total");
constbgButton=document.getElementById("bg");
totalButton.addEventListener("click",()=>{
worker.postMessage("Hello worker! Please do the work for me");
});
worker.onmessage=(message)=>{
showResultOfWorker.innerText=message.data;
};
bgButton.addEventListener("click",()=>{
constbgBody=document.body.style["backgroundColor"];
if(bgBody!=="green"){
document.body.style["backgroundColor"]="green";
}else{
document.body.style["backgroundColor"]="tomato";
}
});