views:

14

answers:

1

Ok so heres whats going on:

Whenever I click on an image nested in an unordered list, it moves to a different part on the page. But when it reaches the last li, I want it not to move. I am trying to find it out if there is anyway that the .last() function can return a boolean back?

Thanks, Rohan

A: 

Instead of .last() which returns the last element in the set, for a given set if you have an element you can use .is() with :last-child, like this:

//abort out at top of the function
if($(this).closest('li').is(':last-child')) return; 

If the <li> is the last in the list, it'll return true for is(':last-child').

Nick Craver