Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Save last count after increment

I'm making a simple counter with a button. I press the button and it increments, that works correctly. But I'm also trying to create a "Save" feature where you can Save your last count. It's returning with "Cannot set properties of null(setting 'innerText').

let buttonCount = 0
let countEl = document.getElementById("count-el")
let saveEl = document.getElementById("save-el")


function increment() {
  buttonCount += 1
  countEl.innerText = buttonCount
  console.log(buttonCount)
}

function save() {
  let countStr = buttonCount + " - "
  saveEl.innerText = countStr
}
<title>Passenger Counter</title>
<h1>People Entered:</h1>
<h2 id="count-el">0</h2>
<script src="index.js"></script>
<button id="increment-butn" onclick="increment()">INCREMENT</button>
<button id="save-butn" onclick="save()">SAVE</button>
<p id="save-el">Previous Entries: </p>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!