Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!not-for-mail From: Jake Jarvis Newsgroups: comp.lang.javascript Subject: Re: baffled trying to call style.display value Date: Tue, 27 Nov 2012 17:33:13 +0100 Lines: 31 Message-ID: References: <8b828e29-6604-45c7-9166-f17e5b39724d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de H880IkFDyzjpbwztkPpO6wQlk4Mc+CtGXbFRFWJ+T36B+yh9GcQv9NF1dUR3zvfL4= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <8b828e29-6604-45c7-9166-f17e5b39724d@googlegroups.com> Xref: csiph.com comp.lang.javascript:17367 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 (