I want to be able to change font color of the first two letters in h1 in JavaScript Posted December 3, 2016 <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> #h1 { color: #000000; } </style> </head> <body> <h1 id ="h1">Discover Australia</h1> </body> </html> "use strict"; function changeColour() { var heading = ["Discover"]; for(var i =0;i<heading.lenght;i++) { heading = heading.split(" "); heading = heading.charAt(0).style.fontColor = "#F00"; heading = heading.charAt(1).style .fontColor = "#F00"; heading = heading.subString.style.fontColor = "#000"; } var result = heading.join(" "); console.log(result); } document.getElementById("h1").addEventListener("onload", changeColour,false);
I want to be able to change font color of the first two letters in h1
in JavaScript
Posted