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,19 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
function cambiarTamanio(factor) {
let parrafo = document.getElementById("texto");
let tamañoActual = window.getComputedStyle(parrafo).fontSize;
let nuevoTamaño = parseFloat(tamañoActual) + factor;
parrafo.style.fontSize = nuevoTamaño + "px";
}
</script>
</head>
<body>
<p id="texto" style="font-size: 16px;">Este es un texto con tamaño ajustable.</p>
<button onclick="cambiarTamanio(2)">Aumentar tamaño</button>
<button onclick="cambiarTamanio(-2)">Disminuir tamaño</button>
</body>
</html>