Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Increment counter each time an element is clicked

// increment counter each time the picture element is clicked
        var counter = 0;//Counter variable starts at 0
        const var_counter = document.querySelector("#out_count");//display the number of clicks
        const elem = document.querySelector("body > div > div.box.kat_kontainer > img");//select the picture
        elem.addEventListener("click", function () {//function to be performed on each click
            counter += 1;//Counter variable is incremented by one
            var_counter.innerHTML = counter;//Display the value of the counter in the display element
        });
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native star rating component 
Javascript :: example of js insecure deserialization field 
Javascript :: clear contents of dependent drop down list automatically javascript stack overflow 
Javascript :: for const 
Javascript :: react-router-dom status code 301 
Javascript :: How To Upload File To Alicloud OSS with node.js and Express 
Javascript :: p5 colored line 
Javascript :: Search specific products in the array in javascript 
Javascript :: id generator using javascript 
Javascript :: Kontol Javascript 
Javascript :: angualr js checknbox not working js 
Javascript :: Iterating over a TypedArray 
Javascript :: js sol 
Javascript :: runecape 
Javascript :: js import 
Javascript :: jitsi npm ERR! code EINTEGRITY npm ERR! sha512-VYzZHHs 
Javascript :: vite esbuild configuration 
Javascript :: return asynchronous result and not undefined 
Javascript :: remove port number from url node js 
Javascript :: js array take a elemt to front 
Javascript :: Node-Red: 2Outputs 
Javascript :: Simple Email Validation, Case Insensitive, w/ All Valid Local Part Characters (whatever tf that means to you...) - Regex 
Javascript :: "send data with window.location.href and get" 
Javascript :: add types to React$Context in flow 
Javascript :: display js variable in html without + 
Javascript :: 5.1.3. Boolean Expressions¶ 
Javascript :: mettre en commentaire vscode 
Javascript :: tekenaja 
Javascript :: convert json to .env node 
Javascript :: JavaScript detect card type 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =