87,910
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<body>
<input type = "button" value = "欢迎比尔盖茨" id = "0" onclick = "welcome();" /><br />
<input type = "button" value = "欢迎哈利波特" id = "1" onclick = "welcome();" /><br />
<input type = "button" value = "欢迎AAB" id = "2" onclick = "welcome();" /><br />
<script>
var person = new Array();
person = [ ["比尔盖茨","工程师" ],["哈利波特","巫师"],["AAB","abc"] ]
var x = document.getElementById("0").id;
var x = x + 1;
document.write(person[0][0] + x )
function welcome(){
var i=this.value;
alert(i);
}
</script>
</body>
</html>
function welcome() {
var i = this.value;
alert(this);//-> [object Window],这里的this指向的是window对象
alert(i);
}
//改写成
function welcome(obj){
alert(obj.value);
}
<input type="button" onclick="welcome(this);" value="button" >