.a:before {
content: 'b';
display: table;
}
如何獲得類'a'的內容值?我嘗試:獲取僞類的價值
`var b = window.getComputedStyle(document.querySelector('a'), ':before').getPropertyValue('content');`
這回我一個錯誤:
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
認爲你錯過了點... querySelector('。a') – Chris
或在他的CSS一個額外的'。 – lshettyl