Una IA como ChatGPT puede ayudarte a crear proyectos con JavaScript. Este curso te guiará paso a paso en cómo dar instrucciones claras y específicas para crear aplicaciones web interactivas.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bienvenida</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
h1 {
color: #333;
text-align: center;
}
</style>
</head>
<body>
<h1 id="mensaje"></h1>
<script>
document.getElementById("mensaje").textContent = "¡Bienvenido a mi página!";
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactividad</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
padding: 50px;
font-family: Arial, sans-serif;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
}
#mensaje {
margin-top: 20px;
font-size: 18px;
}
</style>
</head>
<body>
<button id="miBoton">Haz clic aquí</button>
<p id="mensaje"></p>
<script>
document.getElementById("miBoton").addEventListener("click", function() {
document.getElementById("mensaje").textContent = "¡Hiciste clic!";
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Generador de Números</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
padding: 50px;
font-family: Arial, sans-serif;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
}
#resultado {
margin-top: 20px;
font-size: 24px;
font-weight: bold;
}
</style>
</head>
<body>
<button id="generar">Generar Número</button>
<p id="resultado"></p>
<script>
document.getElementById("generar").addEventListener("click", function() {
let numero = Math.floor(Math.random() * 100) + 1;
document.getElementById("resultado").textContent = "Número generado: " + numero;
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contador</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
}
.contador-container {
text-align: center;
}
button {
padding: 10px 20px;
font-size: 20px;
margin: 0 10px;
cursor: pointer;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
}
#contador {
font-size: 40px;
margin: 0 20px;
}
</style>
</head>
<body>
<div class="contador-container">
<button id="disminuir">-</button>
<span id="contador">0</span>
<button id="aumentar">+</button>
</div>
<script>
let contador = 0;
document.getElementById("aumentar").addEventListener("click", function() {
contador++;
document.getElementById("contador").textContent = contador;
});
document.getElementById("disminuir").addEventListener("click", function() {
contador--;
document.getElementById("contador").textContent = contador;
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lista de Tareas</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 500px;
margin: 20px auto;
padding: 20px;
}
.input-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
input {
flex: 1;
padding: 10px;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 5px;
}
button {
padding: 10px 20px;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
ul {
list-style: none;
padding: 0;
}
li {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
background: #f8f9fa;
margin-bottom: 5px;
border-radius: 5px;
}
.eliminar {
color: red;
cursor: pointer;
}
</style>
</head>
<body>
<div class="input-container">
<input type="text" id="tarea" placeholder="Nueva tarea">
<button id="agregar">Agregar</button>
</div>
<ul id="lista"></ul>
<script>
document.getElementById("agregar").addEventListener("click", function() {
let tarea = document.getElementById("tarea").value;
if (tarea) {
let li = document.createElement("li");
li.innerHTML = tarea + '<span class="eliminar">×</span>';
document.getElementById("lista").appendChild(li);
document.getElementById("tarea").value = "";
li.querySelector(".eliminar").addEventListener("click", function() {
li.remove();
});
}
});
</script>
</body>
</html>