Accessing elements using the DOM By Chloe
let idExample = document.getElementById('example'); idExample.style.background = "yellow"; idExample.style.border = "3px dashed blue";
let classExample = document.getElementsByClassName('JSEXAMPLE'); let classExample2 = document.getElementsByClassName('JSEXAMPLE1'); classExample[0].style.border = "3px solid purple"; classExample[1].style.background = "pink"; for (i = 0; i < classExample2.length; i++) { classExample2[i].style.border="2px dashed black";
let tagExample = document.getElementsByTagName('section'); for (i=0; i< tagExample.length; i++){ tagExample[i].style.background="#cffffa"; tagExample[i].style.border = "2px solid purple"; }
let queryExample = document.querySelector('#queryEx'); queryExample.style.background = "orange";
let queryAllExample = document.querySelectorAll('.Query-Selector-All'); queryAllExample.forEach(query =>{ query.style.border = "2px dashed green"; })