jQuery Bootstrap 滑块控件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16621916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap Slider Controls?
提问by K20GH
I'm currently using http://www.eyecon.ro/bootstrap-slider/which works a treat, however i'd like to output the value in realtime to an input box.
我目前正在使用http://www.eyecon.ro/bootstrap-slider/,它很有效,但是我想将值实时输出到输入框。
The js does this to a tooltip which is fine, however once you leave the slider, you can't see what you set it to. Any suggestions?
js 对工具提示执行此操作,这很好,但是一旦您离开滑块,就看不到您将其设置为什么。有什么建议?
回答by techfoobar
You can log the slider value at real time using the slide
event that is supplied with the plugin.
您可以使用slide
随插件提供的事件实时记录滑块值。
See this demo: http://jsfiddle.net/vMLPF/1/
看到这个演示:http: //jsfiddle.net/vMLPF/1/
Code:
代码:
$('#foo').slider().on('slide', function(_ev) {
$('#bar').val(_ev.value);
});
In the above code, #bar
represents the input box in which you want to show the slider value in real time.
在上面的代码中,#bar
表示要实时显示滑块值的输入框。