ITeye博客

js getTextLen,trim

zhuguo_guo · 2012-01-02 16:26 · js · Web前端 · Markdown

function getTextLen(s) { var newlength=0; for(i=0;i<s.length;i++) { var chrInput; chrInput=escape(s.charAt(i)); if(chrInput.length==6) {newlength=newlength+3;} else {newlength=newlength+1;} } return newlength; }

 function trim(s) 
 {
    var tempStr;
    tempStr = s.replace(/\s+$/g,'');
    tempStr = tempStr.replace(/^\s+/g,'');
    return tempStr;					
  }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。