简体   繁体   中英

JQuery to css write nth-child()

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?

您使用字符串连接:

$(".sliders img:nth-child(" + index + ")").css.......

您可以使用.eq()避免难看的字符串连接。

$(".sliders img").eq(index - 1).css();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM