我在我的 php 项目中使用此范围选择器,因此数据库中存储了 0 到 100 之间的选定范围值。
当页面加载时,我将在范围选择器中设置数据库值,并在提交按钮后将所选范围保存在数据库中 0 到 100
如何在范围选择器中获取和设置范围值。
html
<div class="wrapper" style="width: 400px; margin: 100px auto; padding: 40px;">
<div id="double_number_range" style="margin-top: 50px;"></div>
<input type="submit">
</div>
js
(function() {
"use strict";
$("#double_number_range").rangepicker({
type: "double",
startValue: 0,
endValue: 100,
translateSelectLabel: function(currentPosition, totalPosition) {
return parseInt(100 * (currentPosition / totalPosition));
}
});
}());
最佳答案
可能会有更好的解决方案,例如使用回调函数,但您也可以使用以下代码:
$("input[type=submit]").on('click', function() {
var minValue = parseInt($('span.label.select-label:eq(1)').text(), 10);
var maxValue = parseInt($('span.label.select-label:eq(0)').text(), 10);
console.log(minValue, maxValue);
});
关于javascript - 如何获取双数字范围选择器的选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38675286/