码迷,mamicode.com
首页 > 其他好文 > 详细

面向对象(this的问题二)

时间:2015-02-06 21:44:56      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>

function zgz()
{
var _this=this
this.a=5;

document.getElementById(‘btn‘).onclick=function(){

_this.show();

}
}

zgz.prototype.show=function(){

alert(this.a)

}

window.onload=function(){

new zgz();

}


</script>
</head>

<body>
<input id="btn" type="button" value="按钮">
</body>
</html>

面向对象(this的问题二)

标签:

原文地址:http://www.cnblogs.com/Greenzgz/p/4277977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!