“JQuery Clone Table Row” Code-Antworten

JQuery Clone Row

$( ".element1" ).clone().appendTo( ".element2" );
Lokesh Thakur

JQuery Clone Table Row

/*
<table>
  <tr>
    <td>one</td>
    <td><button type="button" class="js-clone-row">duplicate</button></td>
  </tr>
  <tr>
    <td>two</td>
    <td><button type="button" class="js-clone-row">duplicate</button></td>
  </tr>
</table>
*/

$(function() {
  /** Note: Assumes we are called from somewhere inside a <tr> */
  function cloneClosestTableRow(e) {
    const closestTableRow = $(e.currentTarget).closest('tr');
    const clone = closestTableRow.clone(true);
    const targetContainer = closestTableRow.parent();
    targetContainer.append(clone)
  }
  $('.js-clone-row').on('click', cloneClosestTableRow)
});
What

Ähnliche Antworten wie “JQuery Clone Table Row”

Fragen ähnlich wie “JQuery Clone Table Row”

Weitere verwandte Antworten zu “JQuery Clone Table Row” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen