Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a simple way to get li:gt(-1) in jquery?

Tags:

jquery

Is there a simple way to get li:gt(-1) in jQuery? Or greater than or equal to zero using jQuery's :gt filter?

When the I use the following code, it is not taking li:gt(-1):

 $('#Input li:gt(-1)').each(function()
like image 632
Bruc Walker Avatar asked Dec 27 '22 13:12

Bruc Walker


1 Answers

Change your code to start at 0 instead of -1, and do a "greater-than-or-equal-to" selector:

$('.someClass:eq('+i+'), .someClass:gt('+i+')')

Or, with a little less duplication:

$('.someClass').filter(':eq('+i+'), :gt('+i+')')
like image 125
Elliot Nelson Avatar answered Jan 15 '23 12:01

Elliot Nelson