I have a button with a onclick attribute which is pointing to the function test().
test()
Button 1 <
Pass the this reference to the function, then read textContent property the text content of the node.
this
HTML
Button 1
Script
function test(elem){ var button_name = elem.textContent; }
Fiddle