吕展辉

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1、javascript中构造equals()、trim()方法并应用

 1 String.prototype.Trim = function()
 2 {
 3     return this.replace(/(^\s*)|(\s*$)/g, "");
 4 }
 5 String.prototype.equals = function(s){
 6     return this == s;
 7 } 
 8 var tip = '${tip }';
 9 tip.Trim();
10 if(!tip.equals("${tip }")){
11     if(tip.length != 0){
12         if(tip != null){
13             alert(tip);
14         }
15     }
16 }

 

posted on 2014-03-07 19:11  吕展辉  阅读(278)  评论(0编辑  收藏  举报