JavaScriptHTML + CSS + JavaScript
Draft saved locallyJavaScript · Spaces: 2
Live preview move your pointer inside
Let JavaScript Turn a Style On
CSS already contains a .face.happy rule. JavaScript can activate it by adding the happy class.
face.classList.add("happy");This keeps a useful separation:
- CSS decides what happy looks like.
- JavaScript decides when happy applies.
Learn more
01
Your mission
Add the happy CSS class when the HAPPY button is clicked.
- Select
#faceintoconst face. - Select
#happy-buttonintoconst happyButton. - Create
makeHappy()and callface.classList.add("happy")inside it. - Attach
makeHappyto the button click.
Check my work Run project