rob.m
rob.m

Reputation: 10611

How to show the value inside the handler using bootstrap slider?

I am using boostrap slider and this is how i am implementing it:

$("#yearSlider").slider({step: 20000, min: 0, max: 200000})

How do I get the value inside the handler rather than having it in the tool tip?

Expected result

enter image description here

Upvotes: 2

Views: 1098

Answers (2)

Craig Mason
Craig Mason

Reputation: 168

You can set the value on the slide event in the following way:

$("#yearSlider").on("slide", function(slideEvt) {
  $("#yearSlider .slider-handle").text(slideEvt.value);
});

See fiddle.

Css on the slider handle is a bit funny - it looks like its positioned absolutely, so there may be a better way to style it using the js library's options.

Upvotes: 1

Nelson Teixeira
Nelson Teixeira

Reputation: 6610

just use value property:

Example: try to run this code in console on the page you linked (http://seiyria.com/bootstrap-slider/):

document.getElementById('ex1').value

you'll see the value is returned correctly

Upvotes: 0

Related Questions