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

199
Views
How to make the sessionstorage remember the result of click?

How to make the session storage remember the result of click? Now it's now working and I don't know why.

I want to add a key to the session, and when the key is in the session, the popup is not shown.

Thank you in advance!

let object = document.querySelector('.object');
let tap = document.querySelector('.tap');

function addSessionKey() {
    sessionStorage.setItem('hide', true);
}
function hideObject() {
  for(let i=0; i<sessionStorage.length; i++) {
    let key = sessionStorage.key(i);
    object.classList.add('none');
  }
  hideObject();
}

tap.addEventListener('click', addSessionKey);
tap.addEventListener('click', hideObject);
section {
  height: 100vh;
  background: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
}
div {
  padding: 1rem 3rem;
  background: #999;
}
bottom {
  display: block;
  padding: 1rem;
  background: #666;
  cursor: pointer;
}
.object.none {
  display: none;
}
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>

  <body>
    <section>
      <div class="object">
        <h2>Object</h2>
        <bottom class="tap">Tap</bottom>
      </div>
    </section>
  </body>

</html>

about 4 years ago · Santiago Gelvez
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!