$(document).ready(function(){ var rate='1.000000'; rate=parseFloat(rate); var sign='$'; var cid='2'; var prices=$(".price_n"); if(prices.length>0){ $.each(prices,function(key,val){ old_price=$(val).html().substring(1); old_price=parseFloat(old_price); if(cid=="6") $(val).html(sign+((old_price*100)*(rate*100)/10000).toFixed()); else $(val).html(sign+((old_price*100)*(rate*100)/10000).toFixed(2)); }); } var prices_o=$(".price_o"); if(prices_o.length>0){ $.each(prices_o,function(key,val){ old_price_o=$(val).html().substring(1); old_price_o=parseFloat(old_price_o); if(cid=="6") $(val).html(sign+((old_price_o*100)*(rate*100)/10000).toFixed(0)); else $(val).html(sign+((old_price_o*100)*(rate*100)/10000).toFixed(2)); }); } });