Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda