For each target element, this script will wrap the first letter and the first sentence of the text. This is particularly useful if you need to style Drop Caps or a leading sentence.
$('.myclass p').each(function(){
// Split text at each period.
var text = $(this).text().split('.');
for( var i = 0; i < 1; i++ ) {
// Wrap first letter in span.
var first_letter = '' + text[i].substr(0,1) + '';
// Wrap sentence in span.
text[i] = '' + first_letter + text[i].substring(1, text[i].length) + '';
}
$(this).html(text.join('.'));
});
My Subject
This is just a comment
Add new comment