events - JavaScript: Get Function calling HTML-Object -
hey, yes, know [funcname].caller or arguments.callee.caller can reference function called actual function, - following scenario:
<a href="#" onclick="return something()">test</a>
inside of something() have no chance a-tag, .caller reference, unless alter script in following way:
<a href="#" onclick="return something(this)">test</a>
with "this" i'm passing a-tag reference function there way a-tag reference without explicitly passing function?
well, think doing fine, it's 1 word of code , doesn't harm.using jquery can way
$(function(){ $("body").delegate("a", "click", function(){ alert($(this).html()); }); }); //both code work you
$(function(){ $('a').click( function(){ alert($(this).html()); } ); })
Comments
Post a Comment