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

255
Views
how to pass elemnts to a div

I need to pass this element to another active div when i click on the cart i made an e-commerce website

HTML the cart div is active and the cart the box is addto

<div class="active"> 
                <div class="text">
                    <i class="fa-solid fa-x xmark"></i>
                </div>
            </div> // this is the cart
<div class="row">
        <div class="col col">
            <div class="image">
                <img src="img/products/f1.jpg" alt="">
            </div>
            <div class="text">
                <h1>T-shirt</h1>
                <i class="fa-solid fa-cart-shopping addto"></i>
            </div>
        </div>
        <div class="col col1">
            <div class="image">
                <img src="img/products/f1.jpg" alt="">
            </div>
            <div class="text">
                <h1>T-shirt2</h1>
                <i class="fa-solid fa-cart-shopping addto"></i>
            </div>
        </div>
    </div>

JS

let cart = document.querySelector(".cart");
let cartPage = document.querySelector(".active");
let xMark = document.querySelector(".xmark");
let col1 = document.getElementsByClassName("col1")
let addTo = Array.from(document.getElementsByClassName("addto"));

cart.addEventListener("click",function(){
    cartPage.style.width = "30%";
    cartPage.style.opacity = "1";
    cartPage.style.zIndex = "10";

});
xMark.addEventListener("click",function (){
    cartPage.style.width = "0";
    cartPage.style.opacity = "0";
    cartPage.style.zIndex = "-1";
    
});

i need when i click on addto variable i need to append the col1 to the cartPage

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!