Skip to content

This is a simple JavaScript project that demonstrates how to create a click counter. Every time the button is clicked, the counter value increments by 1 and updates on the screen. This project is great for beginners to understand basic DOM manipulation and event handling in JavaScript.

License

Notifications You must be signed in to change notification settings

narnacle/javascript-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

JavaScript Click Counter

This is a simple JavaScript project that demonstrates how to create a click counter. Every time the button is clicked, the counter value increments by 1 and updates on the screen. This project is great for beginners to understand basic DOM manipulation and event handling in JavaScript.

Project Overview

  • Language: JavaScript
  • HTML: Basic structure with an <h2> tag to display the counter and a button to increment it.
  • JavaScript Features:
    • Initializes a counter.
    • Uses a button click event to increment and display the updated counter.

Features

  • Simple button to increment the counter.
  • Real-time display of counter value.
  • Minimal and easy-to-follow code structure.

Getting Started

  1. Clone the repository or download the files to your local machine.

    git clone https://github.com/narnacle/javascript-counter.git
  2. Open the index.html file in any web browser to see the counter in action.

Code Explanation

  • HTML: Displays a counter initialized at 0, and a button that calls a JavaScript function.
  • JavaScript:
    • Initializes a variable count to store the current counter value.
    • Defines incrementCounter() function, which increments count by 1 and updates the HTML display.
<h2>Counter: <span id="counter">0</span></h2>
<button onclick="incrementCounter()">Click Me!</button>
<script>
    let count = 0;
    function incrementCounter() {
        count += 1;
        document.getElementById("counter").innerText = count;
    }
</script>

Usage

  • Open the index.html file in a browser.
  • Click the "Click Me!" button to see the counter increment by 1 on each click.

License

This project is open-source and available under the MIT License.

Acknowledgements

  • Inspired by beginner JavaScript tutorials and small web projects.
  • Thanks to the open-source community for resources and inspiration.

About

This is a simple JavaScript project that demonstrates how to create a click counter. Every time the button is clicked, the counter value increments by 1 and updates on the screen. This project is great for beginners to understand basic DOM manipulation and event handling in JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages