JS 除法运算

JavaScript011

JS 除法运算,第1张

<script type="text/javascript">

function G(e){return document.getElementById(e)}

</script>

单价:<input type="text" id="p" name="price" onkeyup="this.value=this.value.replace(/[^0-9\.]/g,'')" onblur="G('total').value = this.value / 0.9"/>

金额:<input type="text" id="total" name="total" />

输入完单价,点金额的输入框就好~~

function(a,b){

    var c = 0.00

    if(b != 0){

        c = (a/b).toFixed(2)

    }

    return c

}