The answer to this question was given, but for your future coding reference, you could consider this.
In your HTML, add the name as an attribute to the button and remove the onclick link.
<button id="button" data-name="Mathew" type="button">click</button>
In your JS, grab the button using your identifier, assign a function to the click button, and use the function to display the attribute of the name of the button name.
var button = document.getElementById('button'); button.onclick = myfunction; function myfunction() { var name = this.getAttribute('data-name'); alert(name); }
Good luck.
Demo
source share