Im getting a error menioned above to not use innerHTML please help with this.Getting error in js file. Its just a basic counter im trying to make......
index.html
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div>
<h1>Counter</h1>
<h1 class="counter-display">(..)</h1>
<button class="counter-minus">-</button>
<button class="counter-plus">+</button>
</div>
</body>
</html>
Script.js
let counterDisplayElem = document.querySelector('.counter-display');
let counterMinusElem = document.querySelector('.counter-minus');
let counterPlusElem = document.querySelector('.counter-plus');
let count = 0;
updateDisplay();
counterPlusElem.addEventListener("click", () => {
count++;
updateDisplay();
});
counterMinusElem.addEventListener("click", () => {
count--;
updateDisplay();
});
function updateDisplay() {
counterDisplayElem.innerHTML = count;
};
` and it will work
– angel.bonev Jan 15 '21 at 14:21