Answer the question
In order to leave comments, you need to log in
How to store elements to add using JS?
Situation: on clicking the button I need to add the form. You can do this many times.
I can store the HTML code of this form directly in the JS code as text and just do append.
But is there a "beautiful" way to store such things? In my opinion, it's not cool to store large html chunks right in the code.
Answer the question
In order to leave comments, you need to log in
you make the necessary piece of code in html
you make it hidden
if you need to create a copy of it - you clone it (for example, by copying innerHTML) and paste it in the right place
I store pieces of reusable html in tags right in the text of the page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question