我在IE 11中收到此错误:



的JavaScript

jQuery(document).ready(function($) {
    var $total = $('#total'),
    $value = $('.value');
    $firstName = $('#firstname');
    $lastName = $('#lastname');
    $tour = $('#tour');
    $pledge = $('#pledge');
    $currency = $('#currency');
    $distance = $('#distance');
    $riders = $('#riders');

    $(':input').on('input change', function(e) {
        var total = 1;
        $value.each(function(index, elem) {
            if(!Number.isNaN(parseFloat(this.value)))
                total = total * parseFloat(this.value);
        });
        $total.val(total/10);

        $('#pledgefirstname').text($firstName.val());
        $('#pledgelastname').text($lastName.val());
        $('#pledgetour').text($tour.val());
        $('#pledgepledge').text($pledge.val());
        $('#pledgecurrency').text($currency.val());
        $('#pledgecurrency2').text($currency.val());
        $('#pledgecurrency3').text($currency.val());
        $('#pledgecurrency4').text($currency.val());
        $('#pledgetotal').text($total.val());
        $('#pledgetotal2').text($total.val());
        $('#pledgedistance').text($distance.val());
        $('#pledgeriders').text($riders.val());
    });
});

最佳答案


大多数浏览器(包括IE11)仍不支持该功能。
您应该改用标准的 isNaN 方法:

if (isNaN( parseFloat(this.value) )) { ... }

10-06 01:50