Skip to content

A jQuery plugin for eliminating typographical orphans on select text elements.

Notifications You must be signed in to change notification settings

jschrab/jquery.deorphan.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

jquery.deorphan.js

A jQuery plugin for eliminating typographical orphans on select text elements.

What are orphans?

An orphan is a single word that appears by itself at the end of a paragraph. This script finds the last two words of a selected element and joins them together with a non-breaking space.

For example:

jquery.deorphan.js - before and after example

For more information, check out this Wikipedia entry.

How to use it?

Include the plugin after loading jQuery. Then to activate the plugin add the following code to your own js file.

$('.your-class-name').deOrphan();

You can provide a list of elements you want deOrphan'd as well.

$('.your-class-name, .another-class-name, p, section p').deOrphan();

If you put your JavaScript in the head of your document, make sure your DOM is ready.

$().ready(function() {
	$('.your-class-name').deOrphan();
});

Known Bugs

IE6 doesn't seem to like textContent. You may want to hide this script for IE6 and lower.

Author

Steve Schrab

@megasmack

Special thanks to: @wesselej and @jschrab

License

MIT or GPL

About

A jQuery plugin for eliminating typographical orphans on select text elements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%