jQuery: Multiply a number with 7.5

curly_brackets picture curly_brackets · Jan 17, 2011 · Viewed 12.5k times · Source

I'm about to design a webshop, build upon the Big Cartel webshop system. The nearest currency they use is Euro, but I want Danish Kroner (DKK), which is 7.5 of Euro.

How can I multiply the number within a div.price?

I've found "jQuery Calculate"-plugin, but I can't figure out how it works.

Plugin site: http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm

Thank you in advance...

Answer

Šime Vidas picture Šime Vidas · Jan 17, 2011
$('div.price').text(function(i,v) {
    return Math.round(parseInt(v * 100, 10) * 7.5) / 100;
});

Live demo: http://jsfiddle.net/tbL5r/