this语句的知识点第五点

对不起大家久等了 最后一点 

第五点

  1. 给元素中的某一个事件绑定方法,当事件触发时,执行绑定的方法,方法中的this指向当前元素。

funciton fn(){

   console.log(this)

}

document.getElementById("div1").oncilck=function(){

   //console.log(this)div1

    fn()//window

}

document.getElementById("div1").oncilck=fn;//div1

重点是函数套函数的时候

不要管他怎么定义,看他执行时候的主体。

 

原文地址:https://www.cnblogs.com/lxlym/p/9885639.html