给弱智的javascript添加trim方法

来源:互联网 发布:淘宝盗图怎么电话投诉 编辑:程序博客网 时间:2024/04/28 19:35
转贴别人的东西,时间太久了,不知道是转的谁的!
希望放这里做个笔记吧!

  <script language="javascript">
  
   String.prototype.Trim = function()
   {
   return this.replace(/(^/s*)|(/s*$)/g, "");
   }
   String.prototype.LTrim = function()
   {
   return this.replace(/(^/s*)/g, "");
   }
   String.prototype.RTrim = function()
   {
   return this.replace(/(/s*$)/g, "");
   }
</script>
 
原创粉丝点击