Skip to content

Instantly share code, notes, and snippets.

@gtrufitt
Created April 10, 2013 15:43
Show Gist options
  • Select an option

  • Save gtrufitt/5355763 to your computer and use it in GitHub Desktop.

Select an option

Save gtrufitt/5355763 to your computer and use it in GitHub Desktop.
Use jQuery to add a span around a currency symbol (for currencies with the symbol as the first character and only one char)
// Fancy price - add span around the symbol for styling
$.fancyPrice = function(selector){
$(selector).each(function(){
var text = $.trim($(this).html()),
symbol = text.substr(0,1),
newText = text.replace(symbol, '<span class="symbol">' + symbol + '</span>');
$(this).html(newText);
});
};
$.fancyPrice('.price');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment