I’m not guru of javascript, so don’t blame me much.
My task is to find and replace text inside html page, so every number should be replaced with it’s value multiplied by some amount.
e.g. 123 -> 104.55(123*0.85), 245 -> 208,25(245*0.85) etc.
Currently my code is like following:
$('body').html(
$('body').html().replace(/([0-9\.]+)/g, eval("$1*0.85"))
);
eval(“$1*0.85”) return NaN while trying parseFloat($1)*0.85 also does not return correct results
Can someone advise?
Thanks.
it should be sth like this,
var x = $(‘body’).html();
x = x.replace(/([0-9.]+)/g, function ( x ){ return x*0.85;});
$(‘body’).html(x);
if you do not consider events, etc