ZhipSoft.com
              冬去春來
                  鄭重聲明:本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝!!www.ZhipSoft.com
          posts - 94,comments - 149,trackbacks - 0

          <input name="searchContent" id="searchContent" type="text" onclick="test();">
          <SCRIPT type="text/javascript" language="JavaScript">
          function test(){
           var a  = "abcdef".startWith("abc");
           alert("a : "+a);
           var b  = "abcdef".endWith("def");
           alert("b : "+b);
          }
          String.prototype.endWith=function(str){
          if(str==null||str==""||this.length==0||str.length>this.length)
            return false;
          if(this.substring(this.length-str.length)==str)
            return true;
          else
            return false;
          return true;
          }

          String.prototype.startWith=function(str){
          if(str==null||str==""||this.length==0||str.length>this.length)
            return false;
          if(this.substr(0,str.length)==str)
            return true;
          else
            return false;
          return true;
          }

          </SCRIPT>



                  本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
          posted on 2008-07-07 02:31 ZhipSoft 閱讀(7740) 評論(5)  編輯  收藏 所屬分類: JavaScript

          FeedBack:
          # re: 對js中startWith和endWith的擴展
          # re: 對js中startWith和endWith的擴展
          2009-02-17 15:37 | tsuihwau
          這個好啊。  回復  更多評論
            
          # re: 對js中startWith和endWith的擴展
          2009-12-30 09:37 | 2033
          不攻擊不行啊.
          startsWith 不是startWith
          誤人子弟啊  回復  更多評論
            
          # re: 對js中startWith和endWith的擴展
          2010-03-23 22:35 | Lean
          @2033
          明明可以啊
          不去實踐沒有發言權~~
            回復  更多評論
            
          # re: 對js中startWith和endWith的擴展[未登錄]
          2010-06-23 10:49 | fly
          在IE6中無效。。。  回復  更多評論
            
          主站蜘蛛池模板: 阳春市| 策勒县| 金塔县| 卢湾区| 独山县| 英吉沙县| 铜鼓县| 南乐县| 高陵县| 和政县| 大渡口区| 韶山市| 永新县| 蒙阴县| 察哈| 凤凰县| 赤峰市| 龙里县| 呼伦贝尔市| 南部县| 广西| 广饶县| 射洪县| 集安市| 安仁县| 花莲县| 湖口县| 梁河县| 天津市| 乐清市| 大悟县| 南江县| 平武县| 宜宾市| 峨眉山市| 布拖县| 封丘县| 柘城县| 兴城市| 朝阳县| 靖远县|