Garmaine Staff asked 4 months ago

I would like to append empty html rows.

My desired result is to append html rows and remove its(appended row's) contents.

to achieve it,I apply .html('')method.

But it didn't work well.

My work is like below.

How can I append rows and remove its (appended rows) contents?

Thanks

$(document).ready(function() {
   $("table").on( "click", "tr", function() {
       $("table").append($(this).clone().html(' '));
   });
});
table {
border-collapse:collapse;}

td {
border:solid black 1px;
transition-duration:0.5s;
padding: 5px;
cursor:pointer;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
  <tbody>
    <tr>
      <td>0</td>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
    </tr>
  </tbody>
</table>