Plain javascript Basically i create a counter with reset increment and decrement options.
The one thing that does work on firefox and nowhere else is when i want the counter to have a custom starting value so for the submit function
let txtCounter = document.getElementById("counter");
let submitValue = document.getElementById("submittedValue").value;
counter = 0;
const decrease = () => {
counter--;
txtCounter.textContent = `${counter}`;
};
const reset = () => {
counter = 0;
txtCounter.textContent = `${counter}`;
};
function increase() {
counter++;
txtCounter.textContent = `${counter}`;
}
function submit() {
counter = submitValue;
txtCounter.textContent = `${counter}`;
}
And some html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div class="content">
<h1>Counter</h1>
<h2 id="counter">0</h2>
<div class="buttons">
<input type="number" name="" id="submittedValue" />
<button onclick="{submit()}">submit</button>
<button onclick="{decrease()}">decrease</button>
<button onclick="{reset()}">reset</button>
<button onclick="{increase()}">Increase</button>
</div>
</div>
<script src="./Counter.js"></script>
</body>
</html>