HTML JS

HOW TO CREATE HTML LIST FROM JSON DATA

JSON STRING TO ARRAY var data = SON.parse('["Red","Teal","Blue"]');

CREATE ELEMENT

01

CREATE LIST var ol = document.createElement("ol"); for (let i of data) {   let li = document.createElement("li");   li.innerHTML = i;   ol.appendChild(li); }

APPEND LIST TO CONTAINER document.getElementById(TARGET) .appendChild(ol);

JSON STRING TO ARRAY var data = SON.parse('["Red","Teal","Blue"]');

HTML STRING

02

CREATE LIST var ul = "<ul>"; for (let i of data) { ul += `<li>${i}</li>`; } list += "</ul>";

APPEND LIST TO CONTAINER document.getElementById(TARGET) .innerHTML = ul;