Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide all table rows after a specific number?

Tags:

jquery

hide

I'd like to write some code where it displays a complete listing for a year, but initially only show the first 6 weeks (so, 42 days) and then you can click a button to view the rest (no need for a toggle).

I was going to do this using PHP, and setting a class on each of the ones I'd want to hide, which is fine, I guess, I just wasn't sure if there was a more efficient way of doing it in jQuery.

like image 952
xn dx Avatar asked Nov 11 '11 11:11

xn dx


2 Answers

$("table tr:gt(5)").hide();

will hide all of them after/greater than the sixth row.

like image 109
karim79 Avatar answered Oct 08 '22 19:10

karim79


slice() - http://api.jquery.com/slice/

like image 27
Zoltan Toth Avatar answered Oct 08 '22 18:10

Zoltan Toth