Reputation: 35
so I need to make a slider for school. I know that I can use something like
.sliders img:nth-child(Index) {}
I know it need to be like
$(".sliders img").css.........
My question is how to write Child Index value into nth-child using Jquery?
Upvotes: 0
Views: 61
Reputation: 32921
You can use .eq()
to avoid ugly string concatenation.
$(".sliders img").eq(index - 1).css();
Upvotes: 0
Reputation: 2500
You use string concatenation:
$(".sliders img:nth-child(" + index + ")").css.......
Upvotes: 2