Created
April 1, 2010 14:45
-
-
Save siffring/351881 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wraps the first character of a paragraph with <div class="dropclass"></div> | |
// expects a jQuery paragraph object | |
// ex: dropCap($('.story p:first')); | |
function dropCap($target) { | |
$first_p = $target.html().trim(); // removes any leading whitespace | |
if ($first_p.charAt(0) != '<') { | |
// not a html tag | |
$target.html( '<div class="dropcap">' + $first_p.charAt(0) + '</div> ' + $first_p.substring(1) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment