Skip to content

Commit 9c2106e

Browse files
committed
project1
1 parent a8693aa commit 9c2106e

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

07_projects/projectsset1.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Projects related to DOM
2+
3+
## project link
4+
[Click here] (https://stackblitz.com/edit/dom-project-chaiaurcode?file=index.html)
5+
6+
# Solution code
7+
8+
## project 1
9+
10+
```javascript
11+
const buttons= document.querySelectorAll('.button');
12+
const body= document.querySelector('body');
13+
14+
buttons.forEach(function (button){
15+
console.log(button);
16+
button.addEventListener('click', function(e){
17+
//console.log(e)
18+
//console.log(e.target)
19+
if(e.target.id==='grey'){
20+
body.style.backgroundColor= e.target.id;
21+
}
22+
if(e.target.id==='white'){
23+
body.style.backgroundColor= e.target.id;
24+
}
25+
if(e.target.id==='blue'){
26+
body.style.backgroundColor= e.target.id;
27+
}
28+
if(e.target.id==='yellow'){
29+
body.style.backgroundColor= e.target.id;
30+
}
31+
if(e.target.id==='purple'){
32+
body.style.backgroundColor= e.target.id;
33+
}
34+
});
35+
});
36+
37+
```

0 commit comments

Comments
 (0)