JS
challenger
JS
challenger
  • Getting Started
  • Overview
  • Random Challenge
  • Javascript Basics
  • Javascript Arrays
  • Javascript Objects
  • Javascript Dates
  • Javascript Sets
  • Javascript DOM
    NEW
    • - Select the button element on the page
    • - Query descendent HTML elements
    • - Select multiple HTML elements
    • - Query and exclude HTML elements
    • - Execute function on button click
    • - Execute function when cursor moves onto element
    • - Cursor enters and leaves element
    • - Move element with mouse cursor
    • - Check the checkbox
    • - Get full-name from inputs
    • - Increment the counter on button click
    • - Input filter list
    • - Todo List One
    • - Pop the balloons
    • - Stop and restart the moving button
  • Challenge Rush
Imprint Privacy Policy

Increment the counter on button click

Extend the JavaScript code below to interact with the displayed HTML elements.
On each button click, increase the value of the button by 1.
Confirm your code by clicking the button!
View
<button type="button" id="button">0</button>
HTML
const button = document.getElementById('button'); button.addEventListener('click' , () => { // type in your code here

});
Javascript