Jquery 滑块将标签字分配给值
这有点像这里发布的问题:是或否切换或滑块 - 但我无法得到在这个例子中工作的解决方案。
我有一个水平增量范围滑块,我想对其进行修改,以便将标签解码为值 1 - 2 - 3 的小 - 中 - 大
我已经尝试粘贴一个数组来解码,但我无法将其解码正确工作。
这是我到目前为止所得到的:
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 1,
max: 3,
step: 1,
values: [ 2, 3 ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) +
" - " + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
因此,如果选择位置 2 - 3(默认情况下),标签将显示为“中 - 大”。
任何帮助或指导将不胜感激!
谢谢
This is a bit like the problem posted here: Yes or no toggle or slider - but i can't get the solution to work in this example.
I have a horizontal incremental range slider which i would like to modify so that the labels are decoded to small - medium - large for values 1 - 2 - 3
I've tried sticking an array to decode but i just can't get it to work right.
Here's what i have so far:
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 1,
max: 3,
step: 1,
values: [ 2, 3 ],
slide: function( event, ui ) {
$( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) +
" - " + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
so that if positions 2 - 3 were selected (as is the default), the label would read 'medium - large'.
Any help or direction would be much appreciated!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这又如何呢?
它使用映射器对象而不是数组,但还包含一个返回字符串而不是您自己创建字符串的函数:
What about this?
It uses a mapper object instead of an array but also includes a function that returns a string instead of creating it yourself: