Home arrow HTML arrow Page 3 - Completing a Bulleted Menu Of Links
HTML

Completing a Bulleted Menu Of Links


In the previous part of this two-part tutorial, I began describing how to build a bulleted menu of links, such as you might see on many web sites. These links unfold, so that some headings, when clicked, reveal links below them to pages that are subcategories. In this second part, I will jump right back into the subject, starting with the JavaScript code we need to accomplish the magic.

Author Info:
By: Chrysanthus Forcha
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
March 02, 2009
TABLE OF CONTENTS:
  1. · Completing a Bulleted Menu Of Links
  2. · The expandOrCollapse(leftIDpart, rightIDpart) Function
  3. · Global Variables
  4. · Still on Second Level Event
  5. · Other List-Item Markers

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Completing a Bulleted Menu Of Links - Global Variables
(Page 3 of 5 )

There are two global variables: SndLBullet and timesToIgnore. SndLBullet is initialized to false and timesToIgnore is initialized to zero. I will explain their purposes shortly.

Assume that a first level link bullet (LI element) is clicked. The global variables stay at their initial values. After forming the LI id, the expandOrCollapse() function first checks to see if timesToIgnore == 0. Since the initial value of timesToIgnore is zero, this condition is satisfied.

The function goes on to check if the length of the number part of LI id is 1. If it is 1, it means it was the first level LI element that was clicked. If it is 2, it means it was a second level LI element that was clicked. The IDs were given while bearing this in mind. Since we are talking about the case when the first level LI element is clicked, it means the condition (rightIDpart.length == 1) is satisfied.

The function goes on to check if “SndLBullet == false.” Since the initial value of SndLBullet is false, this condition is satisfied. The function then goes to an innermost block. Remember that the function had developed the UL ID for the corresponding (below) UL element of the LI element clicked. In this innermost block, the function first checks to see if the value of the display property of the corresponding UL element is “none.” If it is “none,” it displays the UL element (which has LI elements with links). If it is block, it removes it. So each time you click a First level LI element you either show its sub-lists or remove it. I will give you the details of this innermost block shortly.

Assume that a second level link bullet (LI element) is clicked. The global variables stay at their initial values for now. After forming the LI id, the expandOrCollapse() function first checks if timesToIgnore == 0. Since the initial value of timesToIgnore is zero, this condition is satisfied.

The function goes on to check if the length of the number part of LI id is 1 It is not 1; it is 2, because the second level link element has been clicked. The else-if condition (rightIDpart.length == 2) is cheeked and it is satisfied.

The function then goes into an innermost block. There, it first set the global variable SndLBullet to true, indicating that a second level LI element has been clicked. In this innermost block, the function first checks if the value of the display property of the corresponding (below) UL element is “none.” If it is “none,” it displays the UL element (which has LI elements with links). If it is “block,” it removes it. So each time you click a second level LI element you either show its sub-lists or remove it. I will give you the details of this innermost block shortly.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials