Adding jsFiddle demos since voting down says my answer is incorrect.
If you want to pull it out of the built-in handler, you can just go through this and then go through in the method ...
onclick='a_function(this)'
function a_function(el) { var id = el.parentNode.parentNode.parentNode.id }
DEMO: http://jsfiddle.net/CUyZ4/
Or, if you don't like repeating parentNode , create a function ...
function up(el, n) { while(n-- && (el = el.parentNode)) ; return el; }
function a_function(el) { var id = up(el, 3).id; }
DEMO: http://jsfiddle.net/CUyZ4/1/
Or use it right on the line ...
onclick='a_function(up(this, 3).id)'
DEMO: http://jsfiddle.net/CUyZ4/2/
user1106925
source share