twitter-bootstrap 如何将 getValue 用于引导滑块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17879563/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:42:16  来源:igfitidea点击:

how to use getValue for bootstrap slider?

javascripttwitter-bootstrapslider

提问by Diadara

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. Can someone help me with this ?

我正在使用这个http://www.eyecon.ro/bootstrap-slider/作为我正在处理的页面中的滑块,我不理解 api。有人可以帮我弄这个吗 ?

$(..).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 事件,但是如何直接访问该值?

回答by DejanG

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(). I hope this is going to be helpful

所以我用$('#slider1').val(). 我希望这会有所帮助

回答by Narendran Parivallal

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 valueattribute of the input tag.

在移动滑块之前,这不会提供任何值。所以使用input 标签的value属性指定初始值。

回答by Alaa M. Jaddou

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

回答by Igor Krupitsky

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