function queryUser(){
var sty = window.getComputedStyle(document.getElementsByClassName("ddd")[0],"");
sty.display="block";
}
错误信息:
Uncaught NoModificationAllowedError: Failed to set the 'display' property on 'CSSStyleDeclaration': These styles are computed, and therefore the 'display' property is read-only.
不能这样做吗?
我想做成当事件触发的时候,这个"ddd"才显示出来.
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你这是取得它的计算值,
修改用elem.style.display=
getComputedStyle 这个API 还没用过~~~
报错 是说 display属性时 只读不能写的 , 所以你 赋值就会报错
sty.style.display="block";
修改样式是要在属性前有style.的,如果是显也可以直接用show方法