Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
683 views
in Technique[技术] by (71.8m points)

javascript - Jquery UI Slider, multiple value output

I am trying to configure a slider to display multiple values with one being a standard number output and the other being an output from a value in an array.

http://jsfiddle.net/YKBRWC/7B5jK/1/

I would like the values in the handle to be the standard 1-100 but the values underneath to correspond with a custom array that I would define.

In other words, how would I link

$("#amount").html(value);

to out an array of something like:

[1=15,2=23,3=26,4=32,5=39]

etc?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Do you mean something like this?

http://jsfiddle.net/EvPTj/5/

var ageInput = $("#ageInput"),
    initialValue = 1,
    values = [];

values = ['',15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39,15,23,26,32,39];

var updateSliderValue = function (e, ui) {
    var slider = $(this).data().slider;
    var index = ui.value || 0;
    if (index) {
        $("#amount").html(index + "=" + values[index]);
        slider.element.find(".ui-slider-handle").text(slider.value());
    }
};

var value = $("#slider").slider("value");
$("#amount").html(value);


ageInput.slider({
    min: 0,
    max: 100,
    slide: updateSliderValue,
    create: updateSliderValue,
    value: initialValue
});

af


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...