guanxf

          我的博客:http://blog.sina.com.cn/17learning

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            71 隨筆 :: 1 文章 :: 41 評論 :: 0 Trackbacks
          function Person(){
            var  age=0;//定義私有成員變量age
            function checkAge(age){
               if(age<0 && age>150){
                   return false;
               }
               return true;
            }
          this.setAge=function(theAge){
            if(checkAge(theAge)){
               age=theAge;    
            }else{
               alert("please input cuerrent age!");
            }
          }
          this.getAge=function(){
               document.write(age);
               return age;
          }
          }
          var per=new Person();
          per.setAge(122);
          per.getAge();
          posted on 2011-12-15 00:56 管先飛 閱讀(1272) 評論(1)  編輯  收藏

          評論

          # re: js封裝屬性和方法 2014-11-10 11:23 21
          213312  回復  更多評論
            


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 威海市| 舟山市| 灵宝市| 庆阳市| 徐汇区| 盐山县| 普格县| 昭苏县| 图木舒克市| 南汇区| 新乡县| 德江县| 安岳县| 临朐县| 仙游县| 江西省| 肇源县| 苍南县| 新巴尔虎左旗| 东莞市| 筠连县| 南川市| 乳山市| 河东区| 永胜县| 嘉鱼县| 涟水县| 灵寿县| 同德县| 博爱县| 尼木县| 克东县| 许昌市| 大竹县| 左云县| 临江市| 德清县| 五大连池市| 吴川市| 永寿县| 申扎县|