Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
108
rated 0 times [  111] [ 3]  / answers: 1 / hits: 24532  / 11 Years ago, thu, october 17, 2013, 12:00:00

I have this code here:



document.getElementById('success').style.display(block);
document.getElementById('success').text(aaaa);


and I get this error, why?



Uncaught TypeError: Cannot read property 'style' of null 

<span id=success style=color:#FFF; display:none;></span>


I moved my code to bottom of the page and I get this new error now



Uncaught TypeError: Property 'display' of object #<CSSStyleDeclaration> is not a function


More From » css

 Answers
60

Should be:



var elSuccess = document.getElementById('success');
elSuccess.style.display = 'block';
elSuccess.innerText = 'aaa';

[#74935] Wednesday, October 16, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bryantc

Total Points: 455
Total Questions: 96
Total Answers: 110

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
;