R
R
Robert2016-04-24 12:24:54
JavaScript
Robert, 2016-04-24 12:24:54

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

2 answer(s)
R
Rafael™, 2016-04-24
@Jowan

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

Y
Yuri Shilka, 2016-04-24
@glitch536

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 question

Ask a Question

731 491 924 answers to any question