Link to home
Create AccountLog in
Avatar of gvilla23
gvilla23Flag for United States of America

asked on

jQuery loop and target a specific <li>

So I have a list item with 10 items in it, I have them in a carousel.

The carousel has only 5 of the <li> viewable and in those I want to target the middle one, even when some some scrolls the carousel.

I can target the third one like this $("ul li:nth-child(3)"), but when I scroll the third <li> moves in the direction of the carousel, I need it fixed on the third viewable <li>.

Thanks,
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

rather than 3, make it n+3.
where n starts from 0, and increments everytime you scroll.
Avatar of gvilla23

ASKER

Can you elaborate with some code, please?
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account