File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments