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  回復  更多評論
            


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


          網站導航:
           
          主站蜘蛛池模板: 新津县| 长武县| 天峻县| 三门县| 抚远县| 那坡县| 白朗县| 盱眙县| 内黄县| 平果县| 宣汉县| 玉树县| 中阳县| 临漳县| 武威市| 兴海县| 冷水江市| 镇康县| 武城县| 湖州市| 额尔古纳市| 湖南省| 尚志市| 思南县| 永吉县| 佛山市| 北安市| 博湖县| 芦溪县| 小金县| 历史| 盈江县| 温宿县| 阳曲县| 临清市| 黄梅县| 临澧县| 兴山县| 巴东县| 星子县| 洪洞县|