Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Clone a card and append to the grid var $newCard = $('#card-template').clone(); $newCard.removeAttr('id'); $newCard.find('h3').text('New Card Title'); $('#grid').append($newCard); // Clone with event handlers $('#add-row-btn').on('click', function () { var $lastRow = $('#data-table tbody tr:last').clone(true, true); $lastRow.find('input').val(''); // clear values $('#data-table tbody').append($lastRow); }); // Clone a form field and give it a new name var $field = $('#email-field').clone(); $field.attr('name', 'email2').attr('id', 'email-field-2'); $field.insertAfter('#email-field');
Result
Open