Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda