How can i get the DOM element which fired onclick, in this situation :
<div onclick="ajax('?section=panel');">Hi</div>
and the ajax function is :
function ajax(url)
{
alert(caller_element.innerHTML); // I need `caller_element` contain a reference to that DIV
...xmlhttp(url)...
}
Note that i cannot change HTML, i can only change ajax() function.
You can use
Function.prototype.callto set the context of a function, like so:It would be just as easy to pass it as an argument, though.