A bit of a background, I am beginner level programmer and I tried making a website that collects the amount of your average daily spending and finds your yearly and monthly spending but for the collecting the amount of money part, I wanted to put class for the but when I tried getElementsByClass, it didn't work while getElementById completely did. Is there a reason why? The code for my program is;
<!DOCTYPE html>
<html>
<head>
<title>SpendCalculator</title>
<script src="SC.js"></script>
<link href="SC.css" rel="stylesheet">
</head>
<body>
<input id="input" type="text" placeholder="Money for breakfast">
<button class="submit" onclick="add()">Submit</button>
<h1 id="total"></h1>
</body>
</html>
HTML
let total = 0;
function add() {
console.log(document.getElementById("input").value)
total += document.getElementsByClassName("input").value
console.log(total)
document.getElementById("total").innerHTML = total + "$!";
}
JS