开发者

jquery :gt() inclusive

开发者 https://www.devze.com 2023-02-15 09:10 出处:网络
I was wondering how to use jQuery\'s :gt() in an inclusive way. I am trying to show/hide table rows dyna开发者_开发百科mically.

I was wondering how to use jQuery's :gt() in an inclusive way. I am trying to show/hide table rows dyna开发者_开发百科mically.

$('#' + 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


use below way..( just a way i suggesting) u can manipulate according to your need

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


A stab in the dark:

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

精彩评论

暂无评论...
验证码 换一张
取 消