Answer the question
In order to leave comments, you need to log in
How to clone the previous element on click?
Good afternoon!
The essence of the problem is the following. There is a block in which there is a text field. It is followed by an "Add more" link. By clicking in front of this link, another same text field appears. And you can do this an infinite number of times. Tell me how to implement it?
Answer the question
In order to leave comments, you need to log in
document.querySelector("button").addEventListener("click", function (e) {
e.target.parentNode.insertBefore(document.createElement("div"), e.target).innerText = "Какой-то текст нового блока";
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question