DEV Community

Cover image for HTML Counter
Maro Gamer
Maro Gamer

Posted on

HTML Counter

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>

Enter fullscreen mode Exit fullscreen mode

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay