mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.9 KiB
1.9 KiB
First words
Now that you know how to make your creation move, what about making it communicate its first words to the world?
Let's put a second button in the top right corner of the page, that will add some text when clicked. Add it in the HTML structure:
<button id="speak-button">Click me to speak</button>
Add the button style in the CSS file:
button#speak-button {
top: 100px;
}
Also add this class to style the text we will add:
.words {
text-align: center;
font-family: sans-serif;
}
In the JS file, like in the previous exercise, get the HTML button element with id
speak-button
and add an event listener on click
event, triggering a function that will:
- create a new HTML element of type
div
- set its text content to "Hello there!"
- set its
className
towords
, that we just added earlier in the CSS - use the
append
method to add it inside thetorso
element
Expected output
This is what you should see in the browser.