<div id="test-content"> <label>Name</label> <p>Test Content</p> </div>
Browser output
Test Content
See the same small UI created three ways: original HTML, Vanilla JavaScript, and json-to-tag
through CDN.
Same browser output. Different construction method.
<div id="test-content"> <label>Name</label> <p>Test Content</p> </div>
Test Content
const div = document.createElement("div");
const label = document.createElement("label");
const text = document.createElement("p");
label.textContent = "Name";
text.textContent = "Test Content";
div.append(label, text);
Test Content
const spec = {
tagName: "div",
children: [
{ tagName: "label",
textContent: "Name" },
{ tagName: "p",
textContent: "Test Content" }
]
};
window.ks.jsonToTag
.buildSpecElement(spec);
Test Content