Answers for "javascript for each li in ul"

0

javascript for each li in ul

<!DOCTYPE HTML>
<html>
	<head>
	</head>
	<body>
		<div id="myList"></div>
		<script type="text/javascript">
		var names = ['vitosh','academy','dot','com'];
		var ul = document.createElement('ul');
		document.getElementById('myList').appendChild(ul);
 
		names.forEach(function(name){
			var li = document.createElement('li');
			ul.appendChild(li);
			li.innerHTML += name;
		});
		</script>
	</body>
</html>
Posted by: Guest on April-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language