<script
type="text/javascript">
String.prototype.EndWith=function(s){
if(s==null||s==""||this.length==0||s.length>this.length)
return false;
if(this.substring(this.length-s.length)==s)
return true;
else
return false;
return true;
}
String.prototype.StartWith=function(s){
if(s==null||s==""||this.length==0||s.length>this.length)
return false;
if(this.substr(0,s.length)==s)
return true;
else
return false;
return true;
}
</script>
</script>
本文介绍了一种在JavaScript中扩展字符串原型的方法,实现了StartWith和EndWith两个实用功能。这两个方法可以方便地检查字符串是否以特定子串开头或结尾。
1285

被折叠的 条评论
为什么被折叠?



