【发布时间】:2013-10-17 03:42:30
【问题描述】:
我这里有这段代码:
document.getElementById('success').style.display("block");
document.getElementById('success').text("aaaa");
我得到这个错误,为什么?
Uncaught TypeError: Cannot read property 'style' of null
<span id="success" style="color:#FFF; display:none;"></span>
我将代码移到页面底部,现在出现这个新错误
Uncaught TypeError: Property 'display' of object #<CSSStyleDeclaration> is not a function
【问题讨论】:
-
你是在元素添加到dom之后运行脚本吗?将代码添加到窗口加载处理程序
标签: javascript css syntax