Ad Code

Remove all child elements from table except for first?

<table id="user-table">
      <tr><td>1</td></tr>
      <tr><td>2</td></tr>
      <tr><td>3</td></tr>   
</table>


$('#user-table tr').slice(1).remove();
<div id="parentDiv">
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
      <div>5</div>
</div>
$('#parentDiv > div:gt(0)').remove();

Post a Comment

0 Comments