mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/LMSGI-2024-25.git
synced 2025-11-09 18:03:06 +01:00
feat(JS): solved ex block 01
This commit is contained in:
24
Unidad_05_Javascript/ejercicios/bloque01/ejercicio07.html
Normal file
24
Unidad_05_Javascript/ejercicios/bloque01/ejercicio07.html
Normal 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>
|
||||
Reference in New Issue
Block a user