1、JavaScript猎取伪元素属性
// Get the color value of .element:before
var color = window.getComputedStyle(
document.querySelector(‘.element’), ‘:before’
).getPropertyValue(‘color’);
// Get the content value of .element:before
var content = window.getComputedStyle(
document.querySelector(‘.element’), ‘:before’
).getPropertyValue(‘content’);
2、css的pointer-events属性
经由过程设置该属性的值为none,能够高效阻挠元素的JavaScript事宜行动(包括click和addEventListener)
基础用法:
.disabled {
pointer-events:none;
}