在js中添加方法

先定義,儘可能定義在前面,不然頁面報錯,會提示undefined。this /** * 計算字符串長度(一個漢字等同於一個英文字母) */ String.prototype.realLength1 = function() { return this.replace(/[^\x00-\xff]/g, "*").trim().length; }; 使用:prototype var result
相關文章
相關標籤/搜索