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

PHOTO EMBED

Saved by @bravocoder #javascript

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

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