`

caller 与 callee

 
阅读更多

 

 

 

<button id="btn2">单击事件2</button>

var btn2 = document.getElementById("btn2");
btn2.onclick=function(){
   alert( getEvent()   );
}

//方法2
function getEvent() {
    if (window.event) return window.event;
    var c = getEvent.caller;//得到谁调用这个函数
    alert(c ); 
    alert(arguments.callee);//得到当前的函数的函数体
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics