1var elements = document.getElementsByClassName("classname");
2
3var myFunction = function() {
4 var attribute = this.getAttribute("data-myattribute");
5 alert(attribute);
6};
7
8for (var i = 0; i < elements.length; i++) {
9 elements[i].addEventListener('click', myFunction, false);
10}
11