ibeautiful
SO的答案沒有一個能像操縱普通DOM一樣操縱pseudoelement的樣式。我做到了。點擊段落,由腳本切換Sectionmark的顏色:http://jsfiddle.net/s3fv8e5v/4/CSSbody{font:200%/1.45charter;}ref::before{content:'\00A7';letter-spacing:.1em;}Thesellercan,underBusinessLaw1782,offerafullrefundtobuyers.functionruleSelector(selector){functionuni(selector){returnselector.replace(/::/g,':')}returnArray.prototype.filter.call(Array.prototype.concat.apply([],Array.prototype.map.call(document.styleSheets,function(x){returnArray.prototype.slice.call(x.cssRules);})),function(x){returnuni(x.selectorText)===uni(selector);});}vartoggle=false,pseudo=ruleSelector("ref::before").slice(-1);document.querySelector("article").οnclick=function(){pseudo.forEach(function(rule){if(toggle=!toggle)rule.style.color="red";elserule.style.color="black";});}