• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

javascript: show/hide function?

Rip the Jacker

Diamond Member
Hello.

I was wondering how I could code a menu (with list items) that can be 'hidden' and 'displayed' by clicking on a link?

HTML:

<ul id="menu">
<li id="main">Contents</li>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>

CSS:

#main {
border:1px solid #ddd;
padding:.05em;
}

JAVASCRIPT?

For the javascript, I want to be able to display/hide the menu by clicking on the first list item 'Content', which has an #id of main.

Something like.. (and this is where i fvck up)

var main = document.getElementById('main');
main.****** = // I don't know how to do unobtrusive event triggers.. but I would want this to get the ParentNode (?) which is the UL #menu and for each time its clicked i want it to either be hidden or displayed.

 
Back
Top