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

重点是函数套函数的时候

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

 

posted on 2018-10-31 20:20  小小丶  阅读(83)  评论(0编辑  收藏  举报