jquery slider with value above it which travels with the slider

前端 未结 3 851
北荒
北荒 2021-02-04 15:42

I\'ve made a slider with query/slider and styled it with css. ( http://jsfiddle.net/9qwmX/ )

I succeeded to put the selected value into a div container; but now I want t

3条回答
  •  时光取名叫无心
    2021-02-04 16:40

    This is how i would have done it. To get you started:

    Make use of the "handle" position:

    var offset = $('.ui-slider-handle .ui-state-default .ui-corner-all"').offset();
    var offsetLeft = offset.left;
    var offestTop = offset.top;
    

    Position your slide value box with absolute positioning:

    #tijdlijnDatum { position: absolute; }
    

    And do something with it in the slide event:

    $( "#slider" ).slider({
       slide: function(event, ui) { 
    
           $('#tijdlijnDatum').css({ left: offsetLeft + 'px'  }); // etc
       }
    });
    

提交回复
热议问题