title: Error : Cannot read property 'replace' of undefined
body: <p>I have javascript code and got an error <strong>Cannot read property 'replace' of undefined</strong>. Can anyone please help me to solve this? This is my code, and I currently using jQuery 2.1.3.</p>
  
  <pre><code>ExpandableTable.prototype.updateInputBoxName=function(){
      $("."+this.cloneClass,this.target).each(function(j,t){
          var n=j+1;
          $("input,textarea",$(t)).each(function(i,v){
              if($(v).attr("name")!=""){
                  var newName=$(v).attr("name").replace(/\d+$/,"")+n;
                  $(v).attr("name",newName);
              }
          });
      });
      return this
  };
  ExpandableTable.prototype.updateInputBoxId=function(){
      var t=this;
      $("."+t.cloneClass,this.target).each(function(j,u){
          var n=j+1;
          $("input,textarea",$(u)).each(function(i,v){
              if($(v).attr("id")!=""){
                  var newId=$(v).attr("id").replace(/\d+$/,"")+n;
                  $(v).removeAttr("id").attr("id",newId);
              }
          });
      });
      return this
  };
  </code></pre>
  
  <p>it says i have an error on <strong>.replace</strong>.</p>
  
  <p>Please help me to solve this</p>