for(let element of document.getElementsByTagName('button')){ element.addEventListener('click',GetInnerHTML); } function GetInnerHTML(){console.log("My content is '" + this.innerHTML + "'");}