我需要两个jquery表单滑块的帮助。我有这个代码
$("#slider").slider({
range: "min",
value: 10,
step: 10000,
min: 100000,
max: 1000000,
});
$('#slider').slider()
.on('slide', function(ev){
var datafirst = ev.value*(Math.pow(1.11, 5));
document.getElementById("bar").innerHTML = datafirst;
});
$("#slider-year").slider({
range: "min",
value: 10,
step: 1,
min: 5,
max: 15,
});
$('#slider-year').slider()
.on('slide', function(ev){
var datasecond = ev.value;
document.getElementById("yeartotal").innerHTML = datasecond;
});
我需要的是从第一个滑块和第二个滑块获取变量并计算它们的全部。
感谢您的回答。
答案 0 :(得分:0)
的 LIVE DEMO 强>
var datafirst = 0;
var datasecond = 0;
$("#slider").slider({
range: "min",
value: 10,
step: 10000,
min: 100000,
max: 1000000,
slide: function( ev, ui ) {
datafirst = ui.value * Math.pow(1.11, 5);
$("#bar").text( datafirst );
}
});
$("#slider-year").slider({
range: "min",
value: 10,
step: 1,
min: 5,
max: 15,
slide: function( ev, ui ) {
datasecond = ui.value;
$("#yeartotal").text( ui.value );
}
});
// you can access at any time your variables
// datafirst and datasecond and calculate whatever you need to.