-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathscript4.js
More file actions
38 lines (25 loc) · 937 Bytes
/
script4.js
File metadata and controls
38 lines (25 loc) · 937 Bytes
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
console.log("This code is executed in the browser");
const stone = document.querySelector('.stone')
const paper = document.querySelector('.paper')
const scissors = document.querySelector('.scissors')
stone.addEventListener('click',()=>{
if(paper.classList.contains('paper')){
paper.classList.add('active');
stone.classList.remove('active');
scissors.classList.remove('active');
}
});
paper.addEventListener('click',()=>{
if(scissors.classList.contains('scissors')){
scissors.classList.add('active');
paper.classList.remove('active');
stone.classList.remove('active');
}
});
scissors.addEventListener('click',()=>{
if(stone.classList.contains('stone')){
stone.classList.add('active');
paper.classList.remove('active');
scissors.classList.remove('active');
}
});