[BNM] CSS Nav quandry...

Mart Gordon mart at minibrighton.co.uk
Thu Nov 13 09:35:48 GMT 2003


Perfect. And so neatly done.

Thanks Jeremy.

Hail to the Keith.

-----Original Message-----
From: Jeremy Keith

Mart Gordon wrote:
> I've got an unordered list as my nav and certain <li>'s will have 
> nested
> lists that are generally hidden, however, on certain pages certain 
> hidden
> lists will be displayed. Now I want to hide them again through the 
> click of
> a button. I'm guessing the easiest way is to use some sort of variable 
> to
> determine whether the hidden <ul> is shown or not.
>
> Does anyone have any ideas of how I could go about this?

You can do this by changing the "display" property of the lists.

Let's say you've got a list within a list like this:

<ul id="mainlist">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="# onclick="return toggleDisplay('sublist')">Toggle 
sublist</a>
	<ul id="sublist" style="display: none;" >
	<li><a href="#">Link</a></li>
	<li><a href="#">Link</a></li>
	</ul>
</li>
<li><a href="#">Link</a></li>
</ul>

In your <head>, you have a JavaScript function called toggleDisplay:

function toggleDisplay(element) {
	if (document.getElementById) {
		if (document.getElementById(element).style.display == "none") {
			document.getElementById(element).style.display = "block";
		} else {
			document.getElementById(element).style.display = "none";
		}
	}
	return false;
}

HTH,

Jeremy
-- 
Jeremy Keith

a d a c t i o

http://adactio.com
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003



More information about the BNMList mailing list