简体   繁体   中英

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

<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

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

allows not to write any javascript code. 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 ). Also note that it must be version 6.1.7 or higher!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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