W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2005


From: Ray Whitmer <ray@xmission.com>
Date: Mon, 9 May 2005 07:28:28 -0600 (MDT)
To: Tommie Westling <Tommie.Westling@Tactics.Se>
cc: www-dom@w3.org
Message-ID: <Pine.LNX.4.63.0505090716490.17733@xmission.xmission.com>

On Thu, 5 May 2005, Tommie Westling wrote:

> Hi,
> I wonder if a can use DOM with XHMTL to do dynamic text features like
> expand and collapse?
> How should the code look like for this scenario:
> When i click on the playername it would expand like this:
> Playername1
> Playername2
> Playername3
> Playername1
> Text1
> Text2
> Text3
> Playername2
> Playername3

This is quite easy to do.  What you need to do is change the value of the
display CSS property of the element in question to make it expand or collapse.

For example:


to make it disappear


to make it reappear

With standards-compliant browsers, you could use the actual display
value dictated by CSS, such as


if it is a table row you are manipulating.

but I have never found a version of IE to support this very well whereas
they all (stanedards compliant and not) support setting it to empty string
which gives you the default displayed form, even if it looks a little odd.

In the above examples, replace "foo" with the ID of the element you want to
make disappear or reappear.  There is more supporting code you need like
deciding when to make it disappear and reappear, what to do on browsers that
have disabled scripting, etc.

This particular attribute falls outside of the current DOM standard (I think it
is in the CSS Object Model, originally defined by this group but transferred to
the CSS group.

Received on Monday, 9 May 2005 13:28:57 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:12 UTC