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 Slang. A 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');
}
}
});
});
};
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!
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...
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...