JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 4 Example 2

Console Log Example
Accessing Children of elements
  • John
  • Paul
  • Carl
  • Helen
		
001window.onload = function(){
		
002	const contentElement = document.getElementById('content');
		
003	const firstChild = contentElement.firstChild;
		
004	console.log(firstChild);
		
005	const LIST = document.getElementById('list');
		
006	const numberOfChildren = LIST.children.length;
		
007	console.log(numberOfChildren);
		
008	for(let i = 0; i < LIST.children.length; i++)
		
009	{
		
010		console.log(LIST.children[i].innerHTML);
		
011	}
		
012}