htmlElement.style 是只读属性

时间:2023-03-09 06:40:55
htmlElement.style 是只读属性

document.getElementById('test').style = 'opacity:0';

在某些机型上,比如苹果 ios 10机型上,会报错。提示 style 属性为只读属性。

建议所有的代码都改为 document.getElementById('test').setAttribute('style','opacity:0')