Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <4798181.JASjUMmgV0@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 27 Nov 2012 17:49:53 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 45 NNTP-Posting-Date: 27 Nov 2012 17:49:54 CET NNTP-Posting-Host: 6125402d.newsspool2.arcor-online.net X-Trace: DXC=SE6l053Z_3Zf8j24CD<3lPA9EHlD;3YcR4Fo<]lROoRQ8kFKPTZ7MIeLZm2SI@ZE;]] X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:17368 Jake Jarvis wrote: > Am 27.11.2012 17:08, schrieb JeffG: >> I am creating a table of contents with nested UL lists. Many of the LI >> tags contain A tags and the UL of a lower-level list. The A tags call a >> function meant to show toggle display of the lower level lists. The link >> passes the "this" keyword to the function, which gets the parent node and >> then finds the sibling UL. For some reason, the function is unable to >> return the style.display value that was set by the CSS file (Loaded >> before the javascript). So the first time I run the function by clicking >> the link, my "if" test always goes to the else statement. What am I doing >> wrong? Here is the function: function TocOpenClose(Anc) { var parenLI; >> var NextUL; parenLI = Anc.parentNode; NextUL = >> parenLI.getElementsByTagName("ul")[0]; >> >> if (NextUL.style.display=="none") >> { >> NextUL.style.display = "block"; >> } >> else >> { >> NextUL.style.display = "none"; >> } >> } >> > > The problem is the style property _only_ reflects inline style > information (
    ). > > One approach could be to use special class names for the elements, you > can check for existence and add/remove them relatively easily. In this case it is better to not hide elements by default, to hide them with client-side scripting when the document has been loaded, and to assign "" instead of "block". The Web site should work without sufficient client-side script support as well. It is prudent to wrap the list into a user-defined widget object that eases modification of the list as an outline. PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from (404-comp.)