【英文】JS获取CSS中定义的伪类中的元素值

Introduction

Get the elements value defined in pseudo-classes in CSS using JS.

Get the elements value in pseudo-classes

1
<div id="div"></div>
1
2
var div = document.getElementById("div");
var content = window.getComputedStyle(div, "before").content;
1
2
var div = document.getElementById("div");
var content = window.getComputedStyle(div, "after").content;

Completion

References

Gold Mining - Si Chen