String.prototype.trimRight=function()  
{  
  return this.replace(/\s*$/g,""); 

解决方案 »

  1.   

    String.prototype.trim=function()  
    {  
      return this.replace(/^\s|\s$/g,""); 

      

  2.   

    谁讲解一下这个函数是什么意思?/^\s|\s$/g
      

  3.   

    照上面写String.prototype.trimRight=function()  
    {  
      return this.replace/^\s|\s$/g,""); 

      

  4.   

    属性值赋值及函数定义有错了!String.prototype.trimRight=function()  
    {  
      return this.replace(/\s*$/g,""); 

    或者:function functioname()  //函数名可以随便定
    {  
      return this.replace(/\s*$/g,""); 

    String.prototype.trimRight=functioname();