简体   繁体   English

使用jQuery修改带有nth-child和:after伪的CSS类

[英]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? 有什么方法可以用after伪代码修改nth-child的CSS?

 $(".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. 元素的css会导致黑色选项卡,如下图所示(前六个项目),我正在制作主题切换器,这就是为什么我需要这样做。

上面元素的结果

I think your best bet would be to use .next(); 我认为您最好的选择是使用.next();。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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