I want to remove all rows of my table except the header.
This is what I\'ve tried but it always deletes all rows and header:
$(\"#<%=tblDetailFour
Try using this:
$('#<%=tblDetailFourn.ClientID%> tr').not(function(){ return !!$(this).has('th').length; }).remove();
This should work, assuming that you don't have any header elements in tbody.
$("#<%=tblDetailFourn.ClientID%> tbody tr").remove();
$('#tblDetailFourn > tbody > tr > td').parent('tr').empty();
What about:
$('#tblDetailFourn tbody').html('');
jsfiddle
Try http://api.jquery.com/child-selector/
$("#<%=tblDetailFourn.ClientID%> > tbody > tr").remove();
What you have should work though.
if you want to delete all the tbody including the tag then use
$("#tblDetailFourn tbody").remove();
it will remove all the tr under the tbody as well as tbody.