使用 JQuery 删除欧元价值和货币格式

Remove Euro Value and money format with JQuery

本文关键字:货币 格式 JQuery 删除 使用      更新时间:2023-09-26

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

€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 + " %");
                }
            });
        });
"€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;