欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  函数中使用 this(默认)
  
  在函数中,函数的所属者默认绑定到 this 上。
  
  在浏览器中,window 就是该全局对象为 [object Window]:
  
  实例
  
  function myFunction() {
  
  return this;
  
  }
  
  函数中使用 this(严格模式)
  
  严格模式下函数是没有绑定到 this 上,这时候 this 是 undefined。
  
  实例
  
  "use strict";
  
  function myFunction() {
  
  return this;
  
  }
  
  事件中的 this
  
  在 HTML 事件句柄中,this 指向了接收事件的 HTML 元素:
  
  实例
  
  <button onclick="this.style.display='none'">
  
  点我后我就消失了
  
  </button>

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64237.shtml