3. Objectives
- Understand the differences
between JS and other
programming languages
- Run JS in the console
- Understand what the DOM is and
how you can modify it
18. Change the content
Have a look at the documentation:
- innerText
- insertAdjacentHTML
- href
19. 2 ways to change the DOM
Dynamic:
- Select elements
- Put listeners
- Trigger actions
Static:
- Select elements
- Change the style
- Change the content
29. Go to https://www.lewagon.com/
and change:
- the backgroundColor of the main
title to ‘red’ or any HEX color
- the “Change your life…” to “I am
changing your website”
Exercise 1
30. Now let’s try:
- Changing the main image to
another image of your choice
- Increasing the size of the font of
the main title and sub-title
Exercise 2
31. Change all the titles of the cards in
the next section so that they all say
“Same thing” rather than “#1”,
“4170+” & “1110+”.
Exercise 3
32. Put an event listener on an element
• change the backgroundColor of
an element to “purple” when you
hover it (check ‘mouseover’
listener in the JS documentations)
Exercise 4
33. Change a bit your function, so that
when you hover an element that is
already red you turn it back to blue,
and viceversa.
* check out ‘mouseenter’ in JS docs
Exercise Bonus
34. Create a function that give you a
random color. Then, call this
function in many eventListeners
around your page to change the
color of their font and/or
backgroundColor.
Exercise Bonus