When the element's first clicked on its color should turn red. That part works. When the element's clicked on a second time it's should turn black, it's initial default color, and so on and so forth. That's the part that doesn't work. Once the element turns red it stays in that "state".
function toggleClass() {
var monday = document.getElementById("monday");
monday.classList.add("redColor");
monday.classList.remove("redColor");
this.classList.toggle("redColor");
}
monday.addEventListener("click", toggleClass)
.greenColor {
color: green;
}
.redColor {
color: red;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Practise App</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div id="monday" class="">Monday</div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>