<p><b>Products</b></p>
<ul class="products">
<li class="product">01 <span>+</span></li>
<li class="product">02 <span>+</span></li>
<li class="product">03 <span>+</span></li>
<li class="product">04 <span>+</span></li>
<li class="product">05 <span>+</span></li>
<li class="product">06 <span>+</span></li>
</ul>
<p><b>Wishlist</b></p>
<div class="box"></div>
function wishlistNewSt() {
let cardBtns = document.querySelectorAll('.product span');
let cardBox = document.querySelector('.box');
for (let cardBtn of cardBtns) {
cardBtn.addEventListener('click', () => {
let item = cardBtn.parentElement;
let clone = item.cloneNode(true);
cardBox.appendChild(clone);
})
}
return;
}
wishlistNewSt();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.