title: Example using attr()
body: <p>Following this question - <a href="https://stackoverflow.com/questions/6985899/extending-clone-table-rows-functionality-changing-row-id">Extending Clone Table Rows functionality - changing row ID</a></p>
  
  <p>The code - <a href="http://jsfiddle.net/EwQUW/58/" rel="nofollow noreferrer">http://jsfiddle.net/EwQUW/58/</a></p>
  
  <p>I want to update the attr. Please check the code and I have included comments to see what I am talking about.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>&lt;table id="table"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;select name="make[]" id="make" onchange="change(this,'model')"&gt;
                      &lt;option value="" selected=“selected”&gt; Please Select &lt;/option&gt;
                      &lt;option value=Ford&gt; Ford&lt;/option&gt;
                      &lt;option value=Nissan&gt; Nissan&lt;/option&gt;
                      &lt;option value=Volvo&gt; Volvo&lt;/option&gt;
                      &lt;option value=BMW&gt; BMW&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
              &lt;td&gt;
                      &lt;select name="model[]" id="model" onchange="change(this,'make')"&gt;
                      &lt;option value="" selected=“selected”&gt; Please Select &lt;/option&gt;
                      &lt;option value=Ford&gt; Fiesta&lt;/option&gt;
                      &lt;option value=Nissan&gt; Mirca&lt;/option&gt;
                      &lt;option value=Volvo&gt; s60&lt;/option&gt;
                      &lt;option value=BMW&gt; M3&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id="country" name="country[]"/&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input id="city" name="city[]" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;button id="add"&gt;Add&lt;/button&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>function change(fld,id) {
      var opt = fld.selectedIndex;
      if (fld[opt].value != ' ') {
          var sel = document.getElementById(id);
          for (var i = sel.options.length -1; i &gt; -1; i--) {
              if (fld[opt].value == sel[i].value) sel[i].selected = true;
          }
      }
  } 
  </code></pre>
  
  <p>When I add a new row, I want the ID, NAME and onchange to be updated with a count or length as you put. </p>
  
  <p>As ID are updated and onchange to id=make to id=make2 so the onchange still works</p>
  
  <p><strong>EDIT AGAIN</strong></p>
  
  <p>Actually names will be an array. So only IDS and Onchange needs updating depending on number of rows</p>