Section 1 - Instruction

Time to put everything together! You've learned to select elements, change content, modify styles, and handle events.

Let's combine all these skills to build a complete interactive feature: a button that changes text when clicked.

Engagement Message

Which of the four skills—selection, content change, event handling, or styling—do you think will be most important for this?

Section 2 - Instruction

Imagine you have this HTML on your page:

Our goal is to make the paragraph's text change when someone clicks the button. Simple but powerful!

Engagement Message

What's the very first step we need to take in our JavaScript file?

Section 3 - Instruction

Step 1: Select both elements we need to work with.

We need to get a reference to the button (to listen for clicks) and the paragraph (to change its text).

Engagement Message

Why do we need to select both elements instead of just one?

Section 4 - Instruction

Step 2: Add an event listener to the button.

This tells JavaScript: "When someone clicks myButton, run the code inside this function."

Engagement Message

What type of event are we listening for in this example?

Section 5 - Instruction

Step 3: Change the paragraph's text inside the event handler function.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal