The code below is a very simple and straight forward function allowing you to attach event listeners to all elements with a specific classname. With the code below, you will know the index number of the class element that is clicked we are assuming in this example the event we are interest in is the CLICK event but you can easily change that to whatever event you wish.
With the code below you can very easily and straight forward create custom code for each index of the class.
In the example below, lets assume we have multiple buttons with the class buttonItem
and we want to code on the buttons CLICK event ...