js 两数相减

时间:2022-09-05 19:45:57

var SecondPrice = document.getElementById("txtSecondPrice");  //秒杀价
            var MarketPrice = document.getElementById("txtMarketPrice");  //市场价
            var SavePrice = document.getElementById("txtSavePrice");      //节省价
       
            SavePrice.value  = Math.round((parseFloat(MarketPrice.value) - parseFloat(SecondPrice.value))*100)/100;//保留2位小数。