Yousef Salama
Yousef Salama

Reputation: 55

clone element jQuery and add parent <tbody> before this element

I have this element

<tr class="group-row">
  <td>1</td>
  <td>2</td>
  <td>3</td>
</tr>

I want to clone it and add <tbody> parent to it to be like this

<tbody>
  <tr class="group-row">
    <td>1</td>
    <td>2</td>
    <td>3</td>
  </tr>
</tbody>

Upvotes: 1

Views: 192

Answers (1)

amine laksir
amine laksir

Reputation: 51

something like this should work :

var $clone = $("#element-to-clone").clone();
$("#where-you-want-to-put-the-clone").append($clone);
$clone.wrap( "<tbody></tbody>" );

Upvotes: 2

Related Questions