面向对象三

2018-04-09  本文已影响0人  Monee121

面向对象中级

  1. 面向对象实例:选项卡

  2. 改写面向过程的选项卡


    image.png
  3. 改写面向对象程序的四要素

  4. this 什么时候会出错

<script>
function Bbb()
{
    var _this=this;
    this.b=5;
    
    document.getElementById('btn1').onclick=function ()
    {
        _this.show();
    };
}

Bbb.prototype.show=function ()
{
    alert(this.b);
};

window.onload=function ()
{
    new Bbb();
};
</script>
</head>

<body>
<input id="btn1" type="button" value="按钮" />
</body>
上一篇 下一篇

猜你喜欢

热点阅读