Your Ad Here

Posted By

marcio on 02/13/10


Tagged

jquery typography widow


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

nightshiftc


remove widow


 / Published in: jQuery
 

URL: http://justinhileman.info/articles/a-jquery-widont-snippet

  1. $('h1,h2,h3,li,p').each(
  2. function(){
  3. $(this).html($(this).html().replace(/\s([^\s<] )\s*$/,'&nbsp;$1'));
  4. }
  5. );

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bobthecow on February 18, 2010

The RegEx in this snippet should be `/\s([^\s

Posted By: bobthecow on February 18, 2010

Apparently markdown code escaping doesn't always work? I'll try again.

The RegEx in this snippet should be:

/\s([^\s
Posted By: bobthecow on February 18, 2010

/\s([^\s<]+)\s*$/

not

/\s([^\s&lt;] )\s*$/

You need to login to post a comment.