Answer the question
In order to leave comments, you need to log in
Why doesn't cloneNode work?
I need to copy the block and paste it, but I can't figure out why cloneNode doesn't work, it throws an error "cloneBlock.cloneNode is not a function"
HTML
<div class="blocks">
<div class="block">
<h1 class="title">Привет 1</h1>
<p>Lorem ipsum dolor 1</p>
</div>
</div>
<button class="copy">Копировать</button>
let cloneBlock = document.getElementsByClassName('.block');
let parent = document.querySelector('.blocks');
let copy = document.querySelector('.copy');
copy.addEventListener('click', function(){
const exemple = cloneBlock.cloneNode(true);
parent.append(exemple)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question