Trying to make kinda WISYWIG editor that creates a div with some inner elements. The div (with all the inner elements structure), once designed, should be serialized (somehow, hope it’s the right term, into string and/or JSON), stored in DB and later inserted to DOM of some other HTML document.
Hence, the questions:
- Which is the best way to serialize a
div? - Which is the best way to de-serialize a div (and insert it to the DOM)?
If you want to grab the HTML code of your DOM elements, you can use
innerHTML. See this fiddle for an example:HTML:
JS