Javascript simple Básicamente, creo un contador con opciones de incremento y decremento de reinicio.
Lo único que funciona en Firefox y en ningún otro lugar es cuando quiero que el contador tenga un valor inicial personalizado para la función de envío
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}`; }y algo de 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>