javascript for each li in ul

Solutions on MaxInterview for javascript for each li in ul by the best coders in the world

showing results for - "javascript for each li in ul"
Jonah
19 Jul 2017
1<!DOCTYPE HTML>
2<html>
3	<head>
4	</head>
5	<body>
6		<div id="myList"></div>
7		<script type="text/javascript">
8		var names = ['vitosh','academy','dot','com'];
9		var ul = document.createElement('ul');
10		document.getElementById('myList').appendChild(ul);
11 
12		names.forEach(function(name){
13			var li = document.createElement('li');
14			ul.appendChild(li);
15			li.innerHTML += name;
16		});
17		</script>
18	</body>
19</html>
20