JQuery: gt () inclusive

I was wondering how to use jQuery: 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 lines, let's say newRowStart = 0 and rowsToShow = 5 . This does not display the first row. Setting it to -1 does not work either. It would be very useful if there was an inclusive method, for example: gte (). Does anyone know how to do this?

thanks

+4
source share
4 answers

One option is to use slice() :

 $('#'+tbodyId) .find('tr') .slice( newRowStart, newRowStart + rowsToShow ) // inclusive of starting point .show(); 
+4
source

I think you need a slice function:

How to select a range of elements in jQuery

+3
source

use below method .. (just a method, I suggest), you can manipulate according to your needs

 $(".someClass").filter(":eq("+ N + "), :gt(" + N + ")")" 
+2
source

Blow in the dark:

 $('#' + tbodyId + ' > tr:not(:lt(' + newRowStart + ')):lt(' + rowsToShow + ')').show(); 
0
source

Source: https://habr.com/ru/post/1342578/


All Articles