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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay