I recently starting learning JS and for some reason I cannot get getElementByClassName to work for me. Here's my code.
//variable to store the ID h1
var id = document.getElementById("first");
//variable to store the class h1
var cs = document.getElementsByClassName("second");
//coloring the id 'first'
id.style.color = "red";
cs.style.color = "blue";
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Site</title>
</head>
<body>
<h1 id="first">This is an ID</h1>
<h1 class="second">This is a class</h2>
<script src="index.js"></script>
</body>
</html>
The element with an ID is changing color but the one with a class isn't. Any help would be greatly appreciated.