Underlining specific letters using jQuery
This was my original use, and it probably could read better using variables, but as a quick and dirty code lift to serve my purposes I was n't overly fussed.
$('.heading').each(function() {
$(this).html(
$(this).html().substr(0, $(this).html().length-2)
+ "<span class='lines'>"
+ $(this).html().substr(-2)
+ "</span>"
);
});
This was a later project, and the nature of making it the middle charachters made it a bit harder, so to keep it cleaner and easier to read I added variables.
$('.largeBoldUnderline span').each(function() {
var str = $(this).html()
var middle = $(this).html().length/2;
var underline = str.substr(middle-1, 2);
$(this).html(
str.substr(0, middle-1)
+ "<span class='lines'>"
+ underline
+ "</span>"
+ str.substr(middle+1)
);
});