Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  46] [ 4]  / answers: 1 / hits: 83418  / 13 Years ago, mon, november 28, 2011, 12:00:00

This is my Javascript:



<script type=text/javascript>
function contactChange() {
var contact = document.getElementbyId(contact);
if (contact.style.display == none) {
contact.style.display = block;
} else {
contact.style.display = none;
}
}
</script>


And here is my site:



http://www.andrewjalexander.com/


More From » html

 Answers
16

It's document.getElementById, not document.getElementbyId. (In JS, name of variables and functions are case-sensitive)



Debugging tip : Look at the JS console (F12 in Google Chrome and IE9, Ctrl+Shift+K in Firefox). In this case, following error can be seen:



Debugging



It shows where the error happened (line 260 in your HTML/JS code) and what the error is(Object #<HTMLDocument> has no method getElementbyId).


[#88880] Friday, November 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;