const copy = document.querySelector('.copy');
copy.addEventListener('click', () => {
const dub = document.createElement(copy.tagName);
dub.className = copy.className;
dub.textContent = copy.textContent;
document.body.append(dub);
})
Или вот так... const copy = document.querySelector('.copy');
copy.addEventListener('click', () => {
const dub = copy.cloneNode();
dub.textContent = copy.textContent;
document.body.append(dub);
})