List Info

Thread: Help with showing/hiding divs onclick




Help with showing/hiding divs onclick
country flaguser name
United States
2007-07-25 13:49:20

Hi folks, just joined the group.

I'm trying to create a template for mobile sites that makes the best use of the small screen
space. I'm using header links with the following script to show/hide the content below:

<a name=";1" />
&lt;h2><;a href=";#1"
onclick="document.getElementById('one').style.display=(document.getElementById('one').st
yle.display== 'block')?'none':'block';">SCHEDULE</a>;</h2>;
<div id="one" class=&quot;text"; style=&quot;display: none;";>
text here
<;/div>

Here's an example online:

http://www.bushidodesigns.net/iphone/mobile/

It works great, but I want to make a modification; if a div is visible and someone clicks on
another link, I want the open one to close before the new one opens. My js is pretty weak,
so I can't figure out quite how to accomplish this. Ideally, I would also like the link to have
a different class when the div is open, so I can use a different background image (like a
down arrow).

Thanks in advance.

Dean H.

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Official Samsung

Yahoo! Group for

supporting your

HDTVs and devices.

New web site?

Drive traffic now.

Get your business

on Yahoo! search.

Find Enlightenment

Yoga groups and

resources on

Yahoo! Groups.

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )