Check out this counter for webs that I made!
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contador de Clicks</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
}
#contenedor {
margin-top: 50px;
}
#contador {
font-size: 64px;
color: #333;
background-color: #f0f0f0;
border: 2px solid #ccc;
border-radius: 6px;
padding: 20px 136px;
display: inline-block;
}
#botonContenedor {
margin-top: 20px;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
border-radius: 5px;
margin: 0 10px;
font-size: 16px;
}
</style>
</head>
<body>
<div id="contenedor">
<span id="contador">0</span>
<div id="botonContenedor">
<button id="botonContador" onclick="sumarClick()">Haz clic para sumar</button>
<button onclick="resetearContador()">Resetear</button>
</div>
</div>
<script>
var contador = 0;
function sumarClick() {
contador++;
document.getElementById("contador").innerText = contador;
}
function resetearContador() {
contador = 0;
document.getElementById("contador").innerText = contador;
}
</script>
</body>
</html>
Top comments (0)