Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>clone demo</title>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<table id="dataTable" border="1">
    <thead>
        <tr>
            <th>
                Name
            </th>
            <th>
                Value
            </th>
        </tr>
    </thead>
    <tr>
        <td>
            Scooby Doo
        </td>
        <td>
            6
        </td>
        <td>
            <input type="Button" value="Add Row" class="AddRow">
        </td>
    </tr>
 </table>
 
</body>
</html>
 
$(function(){
  $("input[type='button'].AddRow").toggle
  (
     function()
    {
       var el = $(this);
       el.closest('tr').clone(true).prependTo(el.closest('table'));
       el.attr("value", "Delete row");
     },
     
    });
   
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers