How to get value from jQuery UI slider?

2019-01-11 16:31发布

I am working on http://gamercity.info/ymusic/. And I am using UI slider as seek bar. While the video is played I want to invoke a seekTo(seconds) function if user clicked anywhere on the seek bar. How to get new value of seconds after click event?

9条回答
太酷不给撩
2楼-- · 2019-01-11 16:34
$("#slider").slider(
{
            value:100,
            min: 0,
            max: 500,
            step: 50,
            slide: function( event, ui ) {
                $( "#slider-value" ).html( ui.value );
            }
}
);

JS FIDDLE EXAMPLE : http://jsfiddle.net/hiteshbhilai2010/5TTm4/1162/

you can have a function like this

function seekTo(seek_value)
{
$("#slider").slider('option', 'value',seek_value);

}
查看更多
手持菜刀,她持情操
3楼-- · 2019-01-11 16:38
  // Price Slider
        if ($('.price-slider').length > 0) {
            $('.price-slider').slider({
                min: 0,
                max: 2000,
                step: 10,
                value: [0, 2000],
                handle: "square",


            });
        }



$(document).ready(function(){

 $(".price-slider").on( "slide", function( event, ui ) {  console.log("LA RECTM");  var mm = $('.tooltip-inner').text(); console.log(mm);   var divide = mm.split(':');   console.log( "min:" +divide[0] + " max:" + divide[1] )     } );




})
查看更多
劳资没心,怎么记你
4楼-- · 2019-01-11 16:41
var val = $("#slider").slider("value");
查看更多
孤傲高冷的网名
5楼-- · 2019-01-11 16:42
$('#slider').slider({
    change: function(event, ui) { 
        alert(ui.value); 
    } 
});​

http://jqueryui.com/demos/slider/

查看更多
放荡不羁爱自由
6楼-- · 2019-01-11 16:47

To read slider value/percentage value at anytime:

var val = $('#slider').slider("option", "value");
查看更多
Animai°情兽
7楼-- · 2019-01-11 16:48
var value=document.getElementById('slider').value;
var a=value.split("specialName")//name=special charcter between minimum and maximum rang
var b=a[0];//this will get minimum range
var c=a[1];//this will get maximum range
查看更多
登录 后发表回答