How to know which is the first and last element with Jquery?

0

Good evening everyone. I have a doubt. I'm doing an image gallery and would like to know how do I know which is the first and last element. Type I have the right and left arrows for previous image or next image. Dai type when I get the last image I want to hide the arrow for the next image and when I have the first image I would like to hide the arrow for the previous image. Can you help me?

    
asked by anonymous 11.05.2015 / 02:41

1 answer

1

You can use the methods last and first

$(".elemento").first(); // primeiro elemento
$(".elemento").last(); // último elemento
    
11.05.2015 / 03:16