Jquery Clone and Increase attri Id -


how can increase number of id after clone. ex: first row id 1 , last row id 2. when click button one, id first same 1 , second 2 , last clone 3. solution this? in advance guys.

<table> <tr id="1">     <td><label>contact name</label></td>     <td>         <select>             <option>1</option>             <option>2</option>             <option>3</option>             <option>4</option>         </select>      </td> </tr> <tr id="2">     <td><label>contact name</label></td>     <td>         <select>             <option>1</option>             <option>2</option>             <option>3</option>             <option>4</option>         </select>      </td> </tr> 

$('.submit').click(function(e){ e.preventdefault() var s = $('table tr:last-child); s.clone(true).insertafter(s);  }); 

$('.submit').click(function(e) {     e.preventdefault();     var s = $('table tr:last-child');     var = parseint(s.attr("id"), 10) + 1;     s.clone(true).insertafter(s).attr("id", i); }); 

this should it. parses number of cloned row , increments it. once row cloned , inserted, sets id attribute of row updated number. example can seen here: http://jsfiddle.net/3gnvs/, uses psuedo code instead of exact code.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -