SixfootJames SixfootJames - 2 months ago 10
HTML Question

Finding the first letter in a span or div using jQuery

I have a tricky situation in that the shopping cart I am using switches from US ($) to South African (R) randomly. The guys who make this cart cannot give me an answer as to when they will be able to fix this, let alone know where the bug is.

What I need to be able to do is find the first letter in my price i.e. $140 and change the dollar to Rand so that it reads R140. This needs to happen even if it doesn't change to $, so if if it comes through as R, I want to be able to find that first letter and make it an R anyways. So that the price will always come out in Rands.

Hope this makes sense?



Try -

$(".price").each(function () {
    var currentText = $(this).text();

Working demo -