I’m trying to remove the decimal values on a money value pulled from json feed:
if I have like: 150,000 I want to have just 150
ere’s my code:
$.getJSON('/static/js/datatest.json', function (result){
$.each(result.events, function(i, item){
$('#isoContainer').append('<h3>£<span class="value">' + item.value.replace(/\.0{0,2}$/, "") + '</span></h3>');
});
});
Why this is not working item.value.replace(/\,0{0,3}$/, "") ?
Because you escape the comma, the correct version is
or if it doesn’t go to the end of line, just
EDIT:
if you can have nonzero values after the
,this is the correct one insteadEDIT 2:
Also check that in the ‘culture’ you are using the , means the start of decimal positions and not the thousands separator