feat(JS): solved ex block 01

This commit is contained in:
Rafa Muñoz
2025-02-24 14:06:10 +01:00
parent 5473730e80
commit 63fecbac6a
7 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
function mostrarValor() {
let input = document.getElementById("numero");
let valor = parseInt(input.value);
let parrafo = document.getElementById("resultado");
if (valor === 0) {
parrafo.style.display = "none"; // Oculta el <p> si el valor es 0
} else {
parrafo.style.display = "block"; // Asegura que se muestre si no es 0
parrafo.innerText = "Valor ingresado: " + valor;
}
}
</script>
</head>
<body>
<input type="number" id="numero" placeholder="Ingresa un número" onblur="mostrarValor()">
<p id="resultado" style="display: none;"></p>
</body>
</html>