jq 修改元素css伪类样式

css伪元素是什么:

  CSS 伪元素用于向某些选择器设置特殊效果。

伪元素有哪些:

  :first-line 伪元素:"first-line" 伪元素用于向文本的首行设置特殊样式。

  :first-letter 伪元素:"first-letter" 伪元素用于向文本的首字母设置特殊样式。

  :before 伪元素:":before" 伪元素可以在元素的内容前面插入新内容。

  :after 伪元素:":after" 伪元素可以在元素的内容之后插入新内容。

例子:

.legend-custom > li:nth-child(8):before {
        background: #CE97B0;
    }

jq修改:

 $('.legend-custom li:nth-child(8)').append("<style>'.legend-custom li:nth-child(8):before{background: #E5B299;}</style>")

效果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/fankse/article/details/119034309
jq