Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #17368

Re: baffled trying to call style.display value

Message-ID <4798181.JASjUMmgV0@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-11-27 17:49 +0100
Subject Re: baffled trying to call style.display value
Newsgroups comp.lang.javascript
References <8b828e29-6604-45c7-9166-f17e5b39724d@googlegroups.com> <ahk8a9FhjhjU1@mid.uni-berlin.de>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


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 (<ul style="...">).
> 
> 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 <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

baffled trying to call style.display value JeffG <jeffgutsell@fuse.net> - 2012-11-27 08:08 -0800
  Re: baffled trying to call style.display value Scott Sauyet <scott.sauyet@gmail.com> - 2012-11-27 08:20 -0800
    Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-10 01:24 +0100
      Re: baffled trying to call style.display value Scott Sauyet <scott.sauyet@gmail.com> - 2012-12-10 05:03 -0800
        Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-10 16:04 +0100
          Re: baffled trying to call style.display value Scott Sauyet <scott.sauyet@gmail.com> - 2012-12-10 08:54 -0800
            Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-10 19:36 +0100
          Re: baffled trying to call style.display value Stefan Weiss <krewecherl@gmail.com> - 2012-12-10 22:45 +0100
            Re: baffled trying to call style.display value Andrew Poulos <ap_prog@hotmail.com> - 2012-12-11 10:19 +1100
            Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-11 00:34 +0100
        Re: baffled trying to call style.display value Scott Sauyet <scott.sauyet@gmail.com> - 2012-12-10 07:39 -0800
          Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-10 17:10 +0100
  Re: baffled trying to call style.display value Jake Jarvis <pig_in_shoes@yahoo.com> - 2012-11-27 17:33 +0100
    Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-27 17:49 +0100
  Re: baffled trying to call style.display value JeffG <jeffgutsell@fuse.net> - 2012-11-27 09:38 -0800
    Re: baffled trying to call style.display value Tim Streater <timstreater@greenbee.net> - 2012-11-27 17:59 +0000
      Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-27 21:01 +0100
        Re: baffled trying to call style.display value Tim Streater <timstreater@greenbee.net> - 2012-11-27 22:32 +0000
          Re: baffled trying to call style.display value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-11-27 23:50 +0100

csiph-web