I was wondering how to use jQuery's :gt() in an inclusive way. I am trying to show/hide table rows dynamically.
$('#' + tbodyId + ' > tr:gt(' + newRowStart + '):lt(' + rowsToShow + ')').show();
If i try to show the first 5 rows say, newRowStart = 0
and rowsToShow = 5
. This will not show the first row. Setting it to -1 doesn't work either. It would be very helpful if there was an inclusive method like :gte(). Does anyone know how to do this?
Thanks
One option is to use slice()
:
$('#'+tbodyId)
.find('tr')
.slice( newRowStart, newRowStart + rowsToShow ) // inclusive of starting point
.show();
I think you want the slice function:
How to select a range of elements in jQuery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With