Numeric DL 2.0

Created Sunday 31st of August 2008 by Andreas Lagerkvist
Copyright © 2008 Andreas Lagerkvist (andreaslagerkvist.com)

Please have a look at the "Other Resources" for bug reports or further help on jQuery. Do not post bug reports or feature requests as comments to unrelated articles. If bug reporting on bugtracker.a-framework.org fails, e-mail me.

What it Does

This tiny plug-in numbers definitions in a definition-list if there are more than one definition for a term. Can be useful for FAQs, actual lists of definitions etc.

How to Use

jQuery('#glossary dl').numericDL();

Example

Jug
A small pitcher.
Vulgar Slang. A woman's breasts.
Bird
The animal of the skies

Example Code

HTML

<div id="jquery-numeric-dl-example">
<
dl>
    <
dt>Jug</dt>
    <
dd>A small pitcher.</dd>
    <
dd>Vulgar SlangA womans breasts.</dd>
    <
dt>Bird</dt>
    <
dd>The animal of the skies</dd>
</
dl>
</
div>

JS

jQuery('#jquery-numeric-dl-example dl').numericDL();

Source Code

jQuery.fn.numericDL = function () {
    return 
this.each(function () {
        
jQuery('dt'this).each(function () {
            var 
numDDs    0;
            var 
dt        jQuery(this);
            var 
dd        dt.next('dd');
            var 
i        1;

            while (
dd.length) {
                
dd dd.next('dd');
                
numDDs++;
            }

            if (
numDDs 1) {
                
dd dt.next('dd');

                while (
dd.length) {
                    
dd.text('(' i++ + ') ' dd.text());
                    
dd dd.next('dd');
                }
            }
        });
    });
};

Download

Plug-in

Requires

Random jQuery Plug-ins

  • Vibrate

    This plug-in makes any element you want "vibrate" every now and then. Can be used in conjunction with blink for maximum annoyance!

    Details

  • Ajax Loader

    Use this plug-in when you want to inform your visitors that a certain part of your page is currently loading. The plug-in adds a faded 'loading-div' o...

    Details

  • Live Search

    Use this plug-in to turn a normal form-input in to a live ajax search widget. The plug-in displays any HTML you like in the results and the search-res...

    Details

More Plug-ins

Recent Comments

  1. Coneelolo on "Phu Quoc, Sihanouk Ville, Koh Chang, Koh Wai & Koh Mak"

    For the help please use http://www.google.com

  2. AL on "Accessible, Stylish Modal Windows With Modern CSS"

    @Matt - What exactly isn't working? "Not working" ...

  3. roboteich on "Accessible, Stylish Modal Windows With Modern CSS"

    This is hardly accessible. Screen reader focus is...

Page cached. Loaded in: 0.0103 second(s).
Last DB change: 2010-09-08 19:34:43
Last file change: 2010-08-12 15:31:16
Cache created: 2010-09-09 09:58:10