Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

increased the value of a counter when a button is clicked in javascript

## MY HTML
<button id='counter'>Click Me To Count</button>
<span id='result'>1</span>

## MY JAVASCRIPT
let counter = document.getElementById("counter")
let result = document.getElementById("result")
let count = 1

counter.addEventListener("click", () => {
  count += 1
  result.innerHTML = count
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: click counter in js 
Javascript :: react focus textarea 
Javascript :: tab adds tab textarea javascript 
Javascript :: iife javascript 
Javascript :: what is 5+5 
Javascript :: react read multiple files with filereader 
Javascript :: get date one week from now javascript 
Javascript :: get src values of set of images inside div with pure JavaScript 
Javascript :: node.js util module 
Javascript :: how to get selected value of a dropdown menu in reactjs 
Javascript :: mysql remove quote on json extract 
Javascript :: javascript button onclick reload page 
Javascript :: stop a site from reloading javascript 
Javascript :: state in constructor javascript 
Javascript :: javascript get array difference 
Javascript :: nuxt query params 
Javascript :: how to go to another page onclick in react 
Javascript :: vue.js 
Javascript :: mongodb push to index 
Javascript :: vue call method after render 
Javascript :: sort array object 
Javascript :: change the way Date.now().toString() is logged 
Javascript :: request animation frame 
Javascript :: string to number 
Javascript :: mongoose put request 
Javascript :: how to add checked in javascript 
Javascript :: jquery display text in div 
Javascript :: Material-ui add comment icon 
Javascript :: switch alert 
Javascript :: count javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =