3

我已经知道如何从标签中获取值,问题是它显示类似

€123,453.28

我需要删除欧元符号和逗号才能进行计算。

当然不去掉小数点

$(document).ready(function () {
            $("#TxtVatExcluded").keypress(function () {
                var invoicedAmmount = $("#MainContent_VehicleInformationControl_LblInvoicePriceValue").text();
                alert(invoicedAmmount);
                if (invoicedAmmount > 0) {
                    var ammountWithoutVat = $("#TxtVatExcluded").val();
                    var result = (ammountWithoutVat / invoicedAmmount) * 100;
                    $("#OutputLabel").html(result + " %");
                }
            });
        });
4

1 回答 1

6
"€123,453.28".replace(/[^\d.]/g,"") // Replace every non digit char or dot char
                                    // With an empty string.

现场演示

所以在你的代码中:

var ammountWithoutVat = $("#TxtVatExcluded").val().replace(/[^\d.]/g,"");
var result = (pareseFloat(ammountWithoutVat, 10) / invoicedAmmount) * 100;
于 2012-05-16T12:04:06.740 回答