Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to hide all the rows in the html table except first two and last row using Jquery
Posted
Updated 9-Oct-14 3:58am
v2
Comments
Sinisa Hajnal 9-Oct-14 10:11am    
What have you tried before? Why can't you google hiding / showing table rows? What is preventing you from filtering the rows BEFORE binding the source to the table?

1 solution

This is one way..You can try this

http://jsfiddle.net/ea0397x1/[^]
 
Share this answer
 
Comments
Dukhabandhu Sahoo 9-Oct-14 12:13pm    
Good solution. You can also combine the statements to display the first 2 and last row like:

$(document).ready(function(){

$("#myTable tr").hide();
$("#myTable").children('tbody').children('tr:nth-child(1), tr:nth-child(2), tr:last').show();
});
Hussainp 9-Oct-14 12:42pm    
Oh..Thank you Dukhabandhu for your comment,,,
I think this is the correct answer....
Shemeemsha (ഷെമീംഷ) 9-Oct-14 23:40pm    
Yes... My answer will only show first and last rows..
Dukhabandhu's answer is correct...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900