array list li code example
Example: how to populate a list in html with javascript
function makeList() {
let listData = [
'Blue',
'Red',
'White',
'Green',
'Black',
'Orange'
],
listContainer = document.createElement('div'),
listElement = document.createElement('ul'),
numberOfListItems = listData.length,
listItem,
i;
document.getElementsByTagName('body')[0].appendChild(listContainer);
listContainer.appendChild(listElement);
for (i = 0; i < numberOfListItems; ++i) {
listItem = document.createElement('li');
listItem.innerHTML = listData[i];
listElement.appendChild(listItem);
}
}
makeList();