jQuery Plugin For Preventing Orphans In Text - Fixorphan.js

jQuery Plugin For Preventing Orphans In Text - Fixorphan.js
File Size: 3.77 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Fixorphan.js is a jQuery plugin for modern web typography that prevents orphans at the end of a paragraph you specify.

How to use it:

1. Link to jQuery library and the jQuery Fixorphan.js plugin as this:

<script src="jquery.min.js"></script>
<script src="jquery.fixorphan.js"></script>

2. Call the function on the target paragraph.

<p class="my-paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec accumsan odio. Suspendisse pulvinar mauris vitae nisl mollis, et aliquam ante ornare. Suspendisse turpis mi, hendrerit a laoreet eget, ultricies rutrum odio. Aliquam scelerisque vel nibh varius hendrerit. Cras ut odio maximus.</p>
$('.my-paragraph').fixorphan();

3. If you wish the last line to have 3 words, you can pass the numLastWords option to the fixorphan() function like so:

$('.my-paragraph').fixorphan({
  numLastWords: 3
});

4. In this example, The plugin finds the last three words of your paragraph and wraps them in an inline element:

<p class="my-paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec accumsan odio. Suspendisse pulvinar mauris vitae nisl mollis, et aliquam ante ornare. Suspendisse turpis mi, hendrerit a laoreet eget, ultricies rutrum odio. Aliquam scelerisque vel nibh varius hendrerit. Cras
  <span class="nowrap">
    ut odio maximus.
  </span>
</p>

This awesome jQuery plugin is developed by hdavtian. For more Advanced Usages, please check the demo page or visit the official website.