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): first examples
This commit is contained in:
26
Unidad_05_Javascript/ejemplo01.html
Normal file
26
Unidad_05_Javascript/ejemplo01.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- el charset iso-8859-1 significa "español" -->
|
||||
|
||||
<script>
|
||||
// Crea un formulario con un input y un botón. Al hacer clic, muestra el nombre y edad ingresados en un div.
|
||||
function mostrarMensaje() {
|
||||
let nombre = document.getElementById("nombre").value;
|
||||
let edad = document.getElementById("edad").value;
|
||||
document.getElementById("resultado").innerHTML = 'Hola, ' + nombre + '. Tienes ' + edad + ' años.';
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input type="text" id="nombre" placeholder="Tu nombre">
|
||||
<input type="number" id="edad" placeholder="Tu edad">
|
||||
<button onclick="mostrarMensaje()">Enviar</button>
|
||||
<div id="resultado"></div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user