JavaScript 2022

Term 3 Wednesday

May - July 2022

This site will be updated live during the sessions

Week 4 Example 1

Hello World

		
001window.onload = function(){
		
002	// code here will run after the html, 
		
003	// images and css have loaded
		
004	// add as many function calls as needed here
		
005	let element1 = document.getElementById('content').innerText;
		
006	console.log(element1); 
		
007	/*
		
008	// this gets a collection of Nodes with the element tag supplied
		
009	let allInsideBody = document.getElementsByTagName('BODY');
		
010	console.log(allInsideBody[0]);
		
011	*/
		
012	let newText = "Overwriting the DOM";
		
013	document.getElementById('content').innerHTML = newText;
		
014	console.log(document.getElementById('content').children.length);
		
015}
		
016
		
017runStraightAway();
		
018
		
019function runStraightAway(){
		
020	//code here will run as soon as the script loads
		
021}