i am facing problem to create clone of my firstSection (div) and paste it on up to secondSection.
<script type="text/javascript">
$(document).ready(function(){
$("#firstSection").clone().prependTo("#secondSection");
});
</script>
<table width="100%" border="1">
<div id="firstSection">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
</div>
<div id="secondSection">
<tr>
<td>9</td>
<td>9</td>
<td>9</td>
</tr>
</div>
</table>
Firstly you can’t have
divelements within atable(unless they’re enclosed within atdorth, so this is probably the result of the browser correcting invalid mark-up, however if you usetbodyinstead ofdiv, it should work:Assuming you want to copy only the contents of the
tbody/#firstSectionelement, and not create multiply-nested elements:JS Fiddle demo.