0 works

How to Access Clicked Element From an Array With the Same Class

dashboard+ Project

Posted by @bravocoder #javascript

Code snippet:

var allActionButtons = document.getElementsByClassName("action-buttons");

for (var i = 0; i < allActionButtons.length; i++) {

  allActionButtons[i].addEventListener('click', functionToRunWhenClicked, false);


var functionToRunWhenClicked = function {
  // Add some stuff here
content_copyCopy to Clipboard

More details:

Must define functionToRunWhenClicked as a function in the same script. This is the same code used for the copy and bookmark buttons community page.

>> Browse more code snippets