Javascript 如何从 JQuery Slider 获取当前滑块值?

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

How to get current slider values from JQuery Slider?

javascriptjqueryjquery-uijquery-plugins

提问by Kanishka Panamaldeniya

I am using jquery slider , i want to all sliders current values when one slider is changing

我正在使用 jquery 滑块,当一个滑块发生变化时,我想要所有滑块的当前值

Slider code:

滑块代码:

var slider = jQuery("<div class='slider'></div>").insertAfter(select)
        .slider({
            min : 0,
            max : 4,
            range : "min",
            value : select[0].selectedIndex + 1,
            slide : function(event, ui) {


            },
            change: function(event, ui) { 


            }
        });

I tried this:

我试过这个:

        change: function(event, ui) { 

            jQuery(".minbeds").each(function(){
                alert(jQuery(this).val());
            });          
        }

but whatever the slider values, it is only alerting the value 1.

但无论滑块值如何,它只会提醒 value 1

enter image description here

在此处输入图片说明

UPDATE:

更新:

   jQuery(".slider").slider("value"); 

will give the current slider value when change , but how can i get all slider values .

更改时将给出当前滑块值,但如何获得所有滑块值。

回答by dsgriffin

Use the following line to access the current values of the slider:

使用以下行访问滑块的当前值:

var val = $('#slider').slider("option", "value");