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

167
Vistas
How to grab an item from local storage that's rendered in the particular div

I'm trying to delete a particular item from the local storage on clicking on a button inside one of the displayed divs.

When I press the button, the needed div is deleted, but I can't get it removed from local storage, so when the page's refreshed it appears again. Local storage Key: watchList Value: ["tt0089880","tt0489270","tt0387564","tt0432348","tt1201607"]

fetch(`https://www.omdbapi.com/?i=${movies[i]}&apikey=123`)
        .then((res) => res.json())
        .then((movie) => {
  containerList.innerHTML += `<div class="movie">})

//here I try to delete it from the local storage, but it doesn't work

containerList.addEventListener("click", (e) => {
  const tgt = e.target.closest("button");
  if (e.target.matches(".watchlist")) {
    tgt.closest(".movie").remove();
    localStorage.removeItem()
  }
})

I don't know how to connect the needed index of the Local Storage array to a particular DIV.

The full code is here: https://codepen.io/btb8293/pen/KKoLOmZ

about 4 years ago · Juan Pablo Isaza
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