Jump to content

Collapse & Expand Javascript Menu?


Solarpitch

Recommended Posts

You shouldn't need an image or glyph.

If the '+' is the [i]hot [/i] element, then it's likely in it's own div or span.
So you could replace the character in that div with [b].innerHTML()[/b] .

Make a function for show() and hide(),  but make a third for [b]toggle()[/b], so that you can use the same function for both actions.
Link to comment
Share on other sites

Figured I'd mark this up for you.
I didn't need a show()/hide() after all ; toggle() did both.

[code]

<script>
function toggle(hot,id)
{
var a = document.getElementById(id).style.display;
if (a != 'block')
{
document.getElementById(id).style.display = 'block';
hot.innerHTML='[-]';
}
else
{
document.getElementById(id).style.display = 'none';
hot.innerHTML='[+]';
}

}
</script>

<style>
div {
background-color:#C0FFEE;
}

.hidden {
display:none;
background-color:#ABCDEF;
}

#hotstuff{
cursor:pointer;
}
</style>

<div>
<span id="hotstuff" onclick="toggle(this,'secret')">[+]</span> &lt;&mdash; expand this row.
</div>
<div class="hidden" id="secret">
blah<br />blah<br />blah<br />blah<br />blah<br />
</div>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.