Created
April 10, 2013 15:44
-
-
Save gtrufitt/5355779 to your computer and use it in GitHub Desktop.
Wrap a span around the pennies on a price
This file contains hidden or 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
| // Fancy price - add span around the pennies for styling | |
| $.fancyPrice = function(selector){ | |
| $(selector).each(function(){ | |
| var price = $(this).html(); | |
| var decimalPosition = price.indexOf('.'); | |
| var afterDecimal = price.substr(decimalPosition,3); | |
| var newPrice = price.replace(afterDecimal,'<span>' + afterDecimal + '</span>'); | |
| $(this).html(newPrice); | |
| }); | |
| }; | |
| $.fancyPrice('.price'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment