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

165
Views
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
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!