Example of using document.getElementsByTagName Clicking on the button below should change the color of the text and background of all the "div" elements on the page. Change content properties Code: // This code is contained in the head element or an external file // This function randomly returns a hex digit: 0-9,A-F function getRandomHexDigit() { return "0123456789ABCDEF".split("")[Math.floor(Math.random() * 16)]; } // This function returns a random color in hex with a preceding # sign function getRandomColor() { var color = "#"; for (var i=0; i<6; i++) color += getRandomHexDigit(); return color; } // This function changes the text and background color of all div elements function changeElements() { var elems document.getElementsByTagName("div"); for (var i=0; i