简体   繁体   English

如何使用getValue作为bootstrap滑块?

[英]how to use getValue for bootstrap slider?

I am using this http://www.eyecon.ro/bootstrap-slider/ for a slider in a page I am working on,I don't understand the api. 我正在使用这个http://www.eyecon.ro/bootstrap-slider/作为我正在处理的页面中的滑块,我不懂api。 Can someone help me with this ? 有人可以帮我弄这个吗 ?

$(..).slider('getValue')

returns the dom element while I saw this in the code 我在代码中看到这个时返回dom元素

$(..).slider().getValue() 

which returns a method not found error. 返回找不到错误的方法。 I am aware of the .slide event which can be used for this,but how do you access the value directly ? 我知道可以用于此的.slide事件,但是如何直接访问该值?

I'am using it this way 我这样用它

<input type="text" id="slider1" class="span2 slider" value="80" data-slider-min="50" data-slider-max="90" data-slider-step="0.1" data-slider-value="83"  data-slider-selection="after" data-slider-tooltip="hide">
 $('.slider').on('slide', function (ev) {
        console.log($('#slider1').val());


    });

So I access value with $('#slider1').val() . 所以我用$('#slider1').val()访问值。 I hope this is going to be helpful 我希望这会有所帮助

The slider is technically a text input field. 滑块在技术上是文本输入字段。

So you can simply use $("#inputFieldID").val() 所以你可以简单地使用$("#inputFieldID").val()

This will not provide any value until the slider is moved. 在移动滑块之前,这不会提供任何值。 So specify the initial value using the value attribute of the input tag. 因此,使用输入标记的value属性指定初始值。

you can use this from the built in function 你可以从内置函数中使用它

$("#rating").slider({
    change: function( event, ui ) {
        userRating = ui.value;
        // this will give you the real value of the slider after the change.
        alert(userRating); 
    }
});

and thank you i thought i coud share this with you guys :D 谢谢你我想我和你们分享这个:D

$('#idSlider').data('slider').getValue();

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

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