Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery clone row

$( ".element1" ).clone().appendTo( ".element2" );
Comment

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)
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: round to nearest decimal javascript 
Javascript :: react hook example 
Javascript :: lifecycle state: defunct, not mounted 
Javascript :: navigator.geolocation.getCurrentPosition(console.log,console.log) undefined 
Javascript :: loop through array react native 
Javascript :: document.queryselectorall extract all href element 
Javascript :: react JSON data to display in a table 
Javascript :: catch javascript 
Javascript :: can we send raw json in get method in flutter 
Javascript :: jquery load 
Javascript :: react native password strength meter 
Javascript :: summation js 
Javascript :: Calculator Function JS Javascript 
Javascript :: node fs promises 
Javascript :: array javascript django 
Javascript :: truncate string in javascript 
Javascript :: 100vh mobile 
Javascript :: convert table to excel reactjs 
Javascript :: jQuery hello world program 
Javascript :: node ssh 
Javascript :: reset form jquery 
Javascript :: images not displaying in react 
Javascript :: get parameter from url using jquery 
Javascript :: node js send javascript 
Javascript :: sum of odd numbers in an array javascript without loop 
Javascript :: regex date 
Javascript :: requestanimationframe js 
Javascript :: vue change specific params/query 
Javascript :: jquery get all classes of a div 
Javascript :: sveltekit tailwind 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =