简体   繁体   中英

set Slider bootstrap value

I have a problem in my bootstrap slider, I want to change its value from javascript, but my code doesn't work for me.

JS:

var val=1;
$("#gravite").slider('setValue',val);
$($(this).attr('data-slider-value')).modal('show');

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" />

This should work.

$('#gravite').slider({
    value : 0,
});

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