Kyle Hamilton
asked on
replace text using regexp on load (add commas to numbers)
Hi,
Any ideas how to add commas to the numbers on page load?
This function works on click but not on load.
Thanks,
Kyle
Any ideas how to add commas to the numbers on page load?
This function works on click but not on load.
$(".houseprice").bind('load click',
function(){
$(this).text($(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
});
Thanks,
Kyle
ASKER
hey leakim971,
that almost did the trick. However, I have multiple house prices on the page, so the result is the combination of all the house prices:
so all the houses now cost:
$12,345,614,600,043,456,44 3,456,412, 340
:)
Thanks,
Kyle
that almost did the trick. However, I have multiple house prices on the page, so the result is the combination of all the house prices:
so all the houses now cost:
$12,345,614,600,043,456,44
:)
Thanks,
Kyle
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Now why didn't I think of that?
Thank you as always :))
Thank you as always :))
you're welcome, thanks
see you soon
see you soon
var txt = $(".houseprice").text();
$(".houseprice").text(t.re
$(".houseprice").bind('cli
function(){
$(this).text($(this).text(
});
})