Advertisement
lignite0

removeOrphan

Aug 10th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.     $.fn.removeOrphans = function() {
  3.         $(this).each(function(index, element) {
  4.             var $element = $(element);
  5.             var html = $element.html();
  6.             html = html.replace(/(\s)([\S])[\s]+/g, "$1$2 ");
  7.             $element.empty().html(html);
  8.         });
  9.     }
  10. })(jQuery);
  11.  
  12. $(function() {
  13.     $('p, h1, h2').removeOrphans();
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement