Menu
Coddy logo textTech

Basic Start and Stop

Lesson 8 of 10 in Coddy's Stopwatch - HTML/CSS/JS Project course.

Let's move to the JS part, it might be a bit harder, but we will do it step by step!

challenge icon

Challenge

Easy

In the JS file:

  • Add a click event listener to the start/stop button
  • Once clicked, change the button text to Stop
  • Once clicked again, change the button text back to Start and so on…

You will need to keep an outside variable that will be toggled each time.

Check hints if stuck!

Try it yourself

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
    <body>
        <!-- Write HTML code here -->
        <script src="script.js"></script>
    </body>
</html>

All lessons in Stopwatch - HTML/CSS/JS Project

1Introduction

Overview

4JS Part

Basic Start and StopProject lessonWorking StopwatchProject lessonResetProject lesson