Javascript: get element's current "onclick" contents
Assuming the tag is well-formed, a tag's attribute can be obtained via Element.getAttribute
.
document.getElementById('test').getAttribute('onclick')
// -> "somefunction"
Hopefully you aren't using onclick
for some unscrupulous purpose like storing data.