Spaces:
Sleeping
Sleeping
Se corrige contador
Browse files- app/index.php +15 -14
app/index.php
CHANGED
|
@@ -11,28 +11,29 @@ $nombre = "Norberto";
|
|
| 11 |
</p>
|
| 12 |
|
| 13 |
<div class="contador">
|
| 14 |
-
<span
|
| 15 |
-
<button onclick="aumentar">Aumenta</button>
|
| 16 |
-
<button onclick="disminuir">Disminuye</button>
|
| 17 |
</div>
|
| 18 |
|
| 19 |
<script>
|
| 20 |
-
let contenedorNumero = document.
|
| 21 |
-
let
|
|
|
|
| 22 |
|
| 23 |
-
function aumentar(){
|
| 24 |
-
numeroActual
|
| 25 |
-
mostrarNumero()
|
| 26 |
}
|
| 27 |
|
| 28 |
-
function disminuir(){
|
| 29 |
-
if (numeroActual == 0) {return}
|
| 30 |
-
numeroActual
|
| 31 |
-
mostrarNumero()
|
| 32 |
}
|
| 33 |
|
| 34 |
-
function mostrarNumero(){
|
| 35 |
-
contenedorNumero.textContent = numeroActual
|
| 36 |
}
|
| 37 |
</script>
|
| 38 |
|
|
|
|
| 11 |
</p>
|
| 12 |
|
| 13 |
<div class="contador">
|
| 14 |
+
<span id="numero">0</span>
|
| 15 |
+
<button onclick="aumentar()">Aumenta</button>
|
| 16 |
+
<button onclick="disminuir()">Disminuye</button>
|
| 17 |
</div>
|
| 18 |
|
| 19 |
<script>
|
| 20 |
+
let contenedorNumero = document.getElementById("numero")
|
| 21 |
+
let numeroString = contenedorNumero.textContent
|
| 22 |
+
let numeroActual = parseInt(numeroString)
|
| 23 |
|
| 24 |
+
function aumentar () {
|
| 25 |
+
numeroActual++
|
| 26 |
+
mostrarNumero()
|
| 27 |
}
|
| 28 |
|
| 29 |
+
function disminuir () {
|
| 30 |
+
if (numeroActual == 0) { return }
|
| 31 |
+
numeroActual--
|
| 32 |
+
mostrarNumero()
|
| 33 |
}
|
| 34 |
|
| 35 |
+
function mostrarNumero () {
|
| 36 |
+
contenedorNumero.textContent = numeroActual
|
| 37 |
}
|
| 38 |
</script>
|
| 39 |
|