JavaScript help error: document.getElementById ("buttons") is zero? I'm using IE7 and Firefox, both browsers display this error most often: Error: document.getElementById ("buttons") is null
I am very new to JS and Ive already tried some tabs and what appears to be the simplest of all, I like the disposal of it too.
Im at a loss what is the problem.
Any help would be greatly appreciated.
Thanx
Here is the JS I've got:
onload = function () (
var e, i = 0;
while (e = document.getElementById ('buttons'). ... getEl ('div') [i + +]) (
if (e.className == 'on' e.className | | == 'off') (
e.onclick = function () (
getEls var = document.getElementsByTagName ('div');
for (var z = 0, z <getEls.length, z + +) (
[GetEls z]. ClassName = [getEls z]. ClassName. ... "Hide");
[GetEls z]. ClassName = [getEls z]. ClassName. ... 'Off');
)
this.className = 'on';
var max = this.getAttribute ('title');
document.getElementById (max). className = "show";
)
)
)
)
Here's the css:
# keys (
width: 450px;
padding: 15px 0 0 0;
line-height: 15px;
)
# Div.off buttons (
color: # 000;
Height: 33px;
margin-right: 2px;
line-height: 33px;
padding: 0 20px;
float: left;
background: url ('../ media/tabs_0.gif ') repeat-x bottom left;
border: 1px solid # ddd;
border-bottom-color: # 000;
cursor: pointer;
position: relative; z-index: 20;
)
# Div.on buttons (
color: # C00;
padding: 0 20px;
margin-right: 2px;
margin-top: 1px;
float: left;
Background: url ('../ media/tabs_2.gif ') repeat-x bottom left;
border: 1px solid # 000;
cursor: pointer;
border-bottom: 0;
Height: 33px;
line-height: 32px;
position: relative; z-index: 100;
)
div.hide (
display: none;
width: 0;
overflow: hidden;
)
div.show (
clear: left;
background: # FFF;
width: 450px;
margin-top: 0;
top: 1px-;
border: 1px solid # 000;
padding: 20px;
position: relative; z-index: 50;
line-height: 18px;
)
img (div.show
float: left;
margin: 0 10px 10px 0;
)
. Clear (clear: both;)
And the 'test' HTML:
id = "buttons"> <div
class = "on" <div title="Details"> <span> Details </ span> </ di ...
class = "off" <div title="Info"> <span> Information </ span> </ d ...
class = "off" <div title="Contact"> <span> Contact Us </ span> </ div>
</ Div>
<div id="Details" class="show">
<p> Although he showed a precocious talent for art and began painting his native Suffolk scenery before he left school, his great originality matured slowly. </ P>
<p> committed to a career as an artist only in 1799 when he joined the Royal Academy Schools and it was not until 1829 that it has been a reluctance Academician, elected by a majority of one vote. </ P>
<p> In 1816 he became financially secure for the death of his father and married Maria Bicknell after a seven-year courtship and in the fact of strong opposition from her family. During the 1820s, he began to win recognition: The Hay Wain (National Gallery, London, 1821) won a gold medal at Paris Salon of 1824 and Constable was admired by> Electronoics Store </ p>
<p> His wife died in 1828, however, and remain.
Posted on July 24, 2010.