1

I've got this script to calculate how much you can get with the amount you are donating.

$(function() {
    var ovalue = 65;
    var kann = 1;
    $("#slider").slider({
        value: ovalue,
        min: 65,
        max: 650,
        step: 65,
        slide: function(event, ui) {
            $("#amount").val(ui.value + " Euro");
            kann = ($("#slider").slider("option", "value") / ovalue >> 0);
            $("#kann").val(kann);
        }
    })
});

the variable kann represents the amount you can get.

At first, kann gets 1 as result because 65/65 is 1. If I move the slider kann should be 2. But 130/65 still is one, although the euro amount changes to 130€. 195€ is 2, etc.

If I am at 195€ and I go back to 130€ kann isn't 1 anymore (which is also false) but kann becomes 3...really? :)

4

1 回答 1

1

只需使用ui.value http://jsfiddle.net/vXzp9/

.slider("option", "value") 总是落后一步,仅 "slide"event之后设置。

于 2013-08-06T18:00:25.763 回答