1

使用此代码笔: http ://codepen.io/anon/pen/RrEbjB

每个滑块每个 15 美元,我需要在调整时获取滑块以更新底部的总数。所有 3 项都应适用于主要总数。

感谢任何帮助使回调正常工作,我删除了我正在处理的代码,因为它破坏了一切......

$(function () {

    $("#range1").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

    $("#range2").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

    $("#range3").ionRangeSlider({
        min: 0,
        max: 100,
        hide_min_max: true
    });

});
4

1 回答 1

0

我想为了其他用户,我最终会发布对我有用的代码。

function sum () {
    var total = (a * 15) + (b * 15) + (c * 15);
    $total.text(total);
}

function sum2 () {
    var totals = (a * 15) + (b * 15) + (c * 15);
    var k = Number(totals) + Number( $('#other_amount').val());
    $grand_total.text(k);
}

$('#other_amount').change(function() {
    sum2();
});

$("#range1").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        a = data.from;
        sum();
        sum2();
    }
});

$("#range2").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        b = data.from;
        sum();
        sum2();
    }
});

$("#range3").ionRangeSlider({
    min: 0,
    max: 25,
    postfix: " in Basket",
    hide_min_max: true,
    hide_from_to: false,
    grid: true,
    keyboard: true,
    keyboard_step: 1,
    force_edges: true,
    onChange: function (data) {
        c = data.from;
        sum();
        sum2();
    }
});
于 2016-02-17T17:34:17.533 回答