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"才显示出来.
getComputedStyle 这个API 还没用过~~~
报错 是说 display属性时 只读不能写的 , 所以你 赋值就会报错
var ddd = document.getElementsByClassName("ddd")[0];
ddd.style.display = 'block'
修改样式是要在属性前有style.的,如果是显也可以直接用show方法
sty.style.display="block";
你这是取得它的计算值,
修改用elem.style.display=