简体   繁体   English

如何设置Bootstrap滑块值

[英]how to set Bootstrap slider value

I use bootstrap slider and looking for a way to set a value of the handle from an other variable , I found this method, but didn't work with me.. data-slider-value is the attribute that contains the value html 我使用bootstrap滑块并寻找一种从其他变量设置句柄值的方法,我找到了这个方法,但是没有用到我.. data-slider-value是包含值html的属性

<input id="gravite" name="gravite" type="text"
              data-provide="slider"
              data-slider-ticks="[1, 2, 3]"
              data-slider-ticks-labels='["Faible", "Moyenne", "Urgent"]'
              data-slider-min="1"
              data-slider-max="3"
              data-slider-step="1"
                data-slider-value=""
              data-slider-tooltip="hide" />

javascript JavaScript的

var val=$(this).attr('gravite');
 $("#gravite").slider('setValue',val);
data-provide="slider" 

allows not to write any javascript code. 允许不编写任何JavaScript代码。 The only thing is that you need to put the dependency on javascipt for bootstrap-slider ( https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/6.1.7/bootstrap-slider.min.js ) in the end of your html (for example, just before ). 唯一的事情是你需要把依赖于javascipt的bootstrap-slider( https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/6.1.7/bootstrap-slider.min.js )放在html的结尾(例如,在之前)。 Also note that it must be version 6.1.7 or higher! 另请注意,它必须是6.1.7或更高版本!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM