您可以重复
document.styleSheets设置
.style的
.cssRules地方
.selectorText比赛伪选择
let sheets = document.styleSheets;let selector = "div::before";let replacementContent = '"after"';for (let sheet of sheets) { for (let rule of sheet.cssRules) { if (rule.selectorText === selector) { rule.style["content"] = replacementContent; } }}div:before { content: "before"; color: red; font-weight: bold; text-align: center; text-shadow: 2px 2px 2px #000; background: green; width: 50px; height: 50px; display: block;}<div></div>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)