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

249
Views
Why cant i add a div to a div?
<!DOCTYPE html>
<html>
    <head>
        <script>
            var cart = document.createElement("div");
            cart.classList.add("cart-row");
            var cart_products = document.getElementsByClassName("cart-items");
            var cartContent = `<div class="cart-item">
                    <span class="cart-item-title">FruitCereal</span>
                </div>
                <span class="cart-price">26.90€</span>
                <div class="cart-quantity">
                    <input class="cart-quantity-input" type="number" value="1">
                    <button class="btn btn-danger" type="button">REMOVE</button>
                </div>`
            cart.innerHTML = cartContent;
            cart_products.append(cart);  
        </script>     
    </head>

    <body>
        <div class="cart-items">
            
        </div>
    </body>

He shows me the error "Uncaught TypeError: cart_products.append is not a function". The same happends with appendChild and .push. I think that I approach the matter completely wrong and overlook something or have misunderstood something.

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!