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

169
Visualizações
what happens with the variable when appended with apprendChild
<body>
<h1 class="titulo">Esto es un <b style="visibility: none;">titulo</b> </h1>
<div style="background-color: aliceblue; height: 200px;" class="container"></div>
<div style="background-color: #ccc; height: 200px;" class="container1"></div>
<script>

    

    /************** Create Elements ****************/
    const container = document.querySelector(".container");
    const container1 = document.querySelector(".container1");

    
    const item = document.createElement("LI");

    item.textContent = "this text go inside";
    
    container.appendChild(item);
    container1.appendChild(item);

    console.log(item); 
    
    
    
</script>

When appended the variable item to one element, It is not possible to append it again to another element.

As I show in the code, I append the "item" variable to the "container" and then append the same "item" variable to the "container1" and it dissapeared from the "container".

How can I do to maintain the value in the variable to append it to many elements?

Thanks

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