this的应用
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title> <script> /*
alert(this); window fn1(this);
function fn1(obj){
obj => window
} oDiv.onclick = function (){
this
fn1(this);
};
function fn1(obj){ obj => oDiv }
*/ window.onload = function (){
var aBtn = document.getElementsByTagName('input');
var that = null; // 空 for(var i=; i<aBtn.length; i++){
/*
aBtn[i].onclick = function (){
// this.style.background = 'yellow'; that = this; fn1();
};
*/
aBtn[i].onclick = fn1;
} function fn1(){
// this => window
// that.style.background = 'yellow'; // this.style.background = 'red';
}
};
</script> </head> <body> <input type="button" value="按钮1" />
<input type="button" value="按钮2" />
<input type="button" value="按钮3" /> </body>
</html>
随机推荐
- vs2015打开cshtml文件失败的解决方法
最近不知道为什么,用vs2015打开cshtml识图文件的时候会报错.也不知道是什么原因,google之后得到解决方法如下: Close VS Delete the content of %Local ...
- Gentoo网络配置
网卡识别配置 要开始配置你的网卡,你首先需要告诉Gentoo RC系统你的网卡. 可以用ifconfig命令查看自己网卡名字: ifconfig -a 网卡名字(如eth0)的识别是通过在/etc/i ...
- 仿bmfn 底部
<!DOCTYPE html> <!-- saved from url=(0019)http://www.bmfn.cn/ --> <html class="k ...
- Erlang OTP gen_event
转自:http://www.myexception.cn/program/1569725.html Erlang OTP gen_event (0) 原英文文档:http://www.erlang.o ...
- padding当高度用时出现的问题
<div class="wrap"> <div class="sudoku"> <div class="sdk-wrap ...
- Hibernate查询、连接池、二级缓存
Hibernate第三天: 1. 对象状态 2. session缓存 3. lazy懒加载 4. 映射 一对一对映射 组件/继承映射 目标: 一.hibernate查询 二.hibernate对连接池 ...
- HDU2202--最大三角形(凸包,枚举)
Problem Description 老师在计算几何这门课上给Eddy布置了一道题目,题目是这样的:给定二维的平面上n个不同的点,要求在这些点里寻找三个点,使他们构成的三角形拥有的面积最大.Eddy ...
- eclipse 中执行 main 函数如何添加参数
我们通常执行 main 函数都是直接在类界面 右键 选择 Run As --> Java Application 但是如何 执行时带有参数呢? 右键 --> Run As --> R ...
- windows做时间服务器,linux和windows时间同步
找了很多的资料,都没有windows做时间服务,linux同步windows的时间的,最后自己找了一些软件,终于搞定了,写出来给大家共享,以免大家多走弯路 首先在http://www.meinberg ...
- RESTful架构2--架构详解
转自:RESTful架构详解 1. 什么是REST REST全称是Representational State Transfer,中文意思是表述(编者注:通常译为表征)性状态转移. 它首次出现在200 ...