Overview
The Fancy Letter Plugin lets you prettify your web page by styling the first letter of any element while keeping the HTML markup clean and readable by both human and machine.
If you like this plugin and you're feeling generous, perhaps you'd also like to visit my amazon.com wish list?
Quick Start Guide
<head> of your document. After these scripts are referenced, you can reference a custom script file to add your fancy letters (preferred) or enter the script directly in the <head> (shown below).<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.fancyletter.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// simple example wraps the first letter of
$('div.content p').fancyletter();
});
</script>
Fancy letters are wrapped in a span tag. Each span is given two classes: a common class ("fancy-letter" by default) and a "letter" class.
For example, after applying the .fancyletter() method to:
<p>This paragraph</p>
it might look like this:
<p><span class="fancy-letter ltr-t">T</span>his paragraph</p>.
See API / Options for more ways to customize the behavior and appearance of the expander.
This sentence begins with a fancy letter, produced by the code below:
$('#demo p:first').fancyletter();
And this sentence begins with a different fancy letter, produced by this code:
$('#demo p:eq(1)').fancyletter({commonClass: 'scarlet-letter'});
characters option. It takes a string that is interpreted as a regular expression. $('#demo-divs > div').fancyletter({ltrClassPrefix: 'bg-', characters: '[A-S]'});
Fancy Letter Plugin API / Options
The Fancy Letter Plugin API provides a single method with a few options.
Feel free to send bug reports or feature requests to the jQuery Google Group.
fancyletter(options)- Wraps a span element (with classes) around the first letter of all elements matched by the jQuery selector.
$.fn.fancyletter.defaults = {
commonClass: 'fancy-letter',
ltrClassPrefix: 'ltr-',
characters: '[a-zA-Z]',
bgImgPath: null,
bgImgExt: null
};
Download
The Fancy Letter Plugin is available at: http://plugins.learningjquery.com/fancyletter/jquery.fancyletter.js.Support
Support for the Fancy Letter Plugin is available through the jQuery Mailing List. This is a very active list to which many jQuery developers and users subscribe.