โ Back to HTML DOM
Question 143
Increment a Counter
Increment a Counter
The span with id="counter" holds the number 5. Read it, add 1, and write the new value (6) back as its text. Platform-Provided HTML (READ-ONLY): <span id="counter">5</span> Steps: 1. Read the current text and convert it to a number withparseInt(). 2. Add 1 and assign the result back totextContent.
Expected Output:
<span id="counter">6</span>
Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.