|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Greetings,
First time poster. URL I looked through the archives but I could not find what I was looking for. I am attempting to build an array of elements using javascript so that I can control the style: display of a div tag. The first part of my function acts as I would suspect. But when I try to get the value of the attribute 'class' it tells me it is null. I can get the value of other attributes but not class. Any ideas in what I am doing wrong? Sample div: <div id="Main" class="menu" style="display: show; margin-left: 0px;"> <a href="#" onclick="collapse(Main); return false"><img src="images/more.gif" name="MainNav" width="9" height="9" border="0" alt="more"></a> <a href="#http://main" class="menu">Main</a><br /> </div> menuBuilder Function: function menuBuilder() { var i; // IE 4 if (document.all) { for(i = 0; i < document.all('all_objects').all.length; i++) { // Feed the menu if (document.all('all_objects').all[i].className == 'menu' | | document.all('all_objects').all[i].className == 'submenu' | | document.all('all_objects').all[i].className == 'links') { document.menu.dropdown[document.menu.dropdown.length] = document.all('all_objects').all[i]; } } } // W3C Compliant for IE5, Netscape 6 and above. // Begin Problem Code else if (document.getElementsByTagName && document.getElementById) { var contained = document.getElementById ('all_objects').getElementsByTagName('div'); for(i = 0; i < contained.length; i++) { if ((contained[i].getAttribute('class') == 'menu') | | (contained[i].getAttribute('class') == 'submenu') | | (contained[i].getAttribute('class') == 'links')) { document.menu.dropdown[document.menu.dropdown.length] = contained [i].getAttribute('id'); } } } // Temporary else { collapse(0); } } |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > getattribute |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|