3
I was watching a tutorial on slider for jQuery, and in a part of the code, in which the goal was to return to the first image, the author of the code did it in a way that I do not know, and also did not know how to search it in Google:
$(".ativo").fadeOut().removeClass("ativo");
$("#slide img:eq(0)").fadeIn().addClass("ativo");
The part of, $("#slide img:eq(0)")
left me confused, img:eq(0)
?
How does it work :eq(0)
?
Look Sergio, spectacular reply, responded perfectly, and even suggested other ways, congratulations for the work you’ve been doing here, see more!
– Ale
@Alexandrec.Caus thank you!
– Sergio
Just reinforcing the beautiful explanation of @Sergio, when we use
$('#slide img').eq(-1)
, return the last element of the group. Similarly, we can use the "pseudo-selector":last
.– Wallace Maxters