简体   繁体   中英

Modifying css class with nth-child and :after pseudo using jQuery

Is there any way to modify the css of nth-child with after pseudo?

 $(".product-block:nth-child(-n+6):after").css("background-color", "#" + col6);

The css of the element results in the black tab as you can see below (to the first six items), I'm making a theme switcher which is why I'm needing to do this.

上面元素的结果

I think your best bet would be to use .next();

$(".product-block:nth-child(-n+6)").next().css("background-color", "#" + col6);

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