Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 900 Bytes

README.md

File metadata and controls

19 lines (16 loc) · 900 Bytes

color-changer

This is a color changer project - a basic level project to learn javascript

steps to build this basic project

in HTML

1.) create a div element in body.
2.) create 4 span tag in div element you have created earlier.
3.) give class and id to these span elements.
4.) class to make the buttons and id for the colors.

in JAVASCRIPT

1.) select buttons using querySelectorAll because we need buttons for click event.
2.) select body using querySelector because we need to change background-color of body.
3.) Now, for each button there must be an eventListener so that when we click on button we get event e from that button.
4.) Now check e.target.id == 'color' and change body's background color = color or e.target.id.
5.) two methods to check and change background color:-
i) if statement.
ii) switch statement.