Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js addeventlistener foreach

var buttons = document.querySelectorAll('.btn-click-me');
for (var i = 0; i < buttons.length; i++) {
    var self = buttons[i];

    self.addEventListener('click', function (event) {  
        // prevent browser's default action
        event.preventDefault();

        // call your awesome function here
        MyAwesomeFunction(this); // 'this' refers to the current button on for loop
    }, false);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: access variable from another function javascript 
Javascript :: js sort 
Javascript :: js delete json element 
Javascript :: momentjs 
Javascript :: add element into array 
Javascript :: react useid hook 
Javascript :: match city regex 
Javascript :: async await promise all javascript 
Javascript :: json server paging 
Javascript :: array of string mongoose 
Javascript :: javascript fullscreen 
Javascript :: javascript foreach url parameter 
Javascript :: delete element html javascript 
Javascript :: popup in browser js 
Javascript :: set localstorage value 
Javascript :: bitfield permissions discord,.js 
Javascript :: how to get input name in javascript 
Javascript :: javaScript getDay() Method 
Javascript :: JavaScript Split the string into an array of characters 
Javascript :: bootstrap open tab from link data-toggle="tab" 
Javascript :: how to stop type text texbox in javascript 
Javascript :: mongoose find multiple and update 
Javascript :: how to show calendar in javascript 
Javascript :: node.js log to file 
Javascript :: select2 multi select get selected value 
Javascript :: how click button and redirect angular 
Javascript :: js === 
Javascript :: javascript filter map array of objects 
Javascript :: js hover event 
Javascript :: add mute button to html5 video player 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =