Numeric DL 2.0

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

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 woman's 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

blog comments powered by Disqus

Random jQuery Plug-ins

  • Tag Sizes

    Use this plug-in on a list of tags (li:s) and it will use whatever numbers found in the list to give each tag a corresponding size.

    Details

  • Text Shadow

    Frankly a rather crappy text-shadow plug-in (can one be done well? :) but nevertheless it does the job in some cases.

    Details

  • Form Hints

    Using this plug-in you can add a descriptive hint to any form-control you may have on your site.
    Add a hint by giving the form-control a title-attri...

    Details

More Plug-ins

Recent Comments

Powered by Disqus
Page cached. Loaded in: 0.0366 second(s).
Last DB change: 2012-04-02 11:06:05
Last file change: 2012-04-25 20:30:39
Cache created: 2012-05-18 06:24:47