0

I need to set using jquery the height property of range input. I came across a lot of answers that says that it is directly not possible, and you need to do a workaround , here is the link, or this link

CSS :

input[type="range"]::webkit-slider-thumb {
      height : 15px;
}

The workaround proposed is to add another css class with new height for instance :

.newHeight::webkit-slider-thumb {
      height : 45px;
}

and finally you can set the new height by adding (or toggle) the new class :

JQuery :

$('html').addClass('newHeight');

This is working fine, but my problem is that the new height should be variable in my case; I don't have the exact value, it is computed based on other parameters on page load. So is it possible to set in this case the height of the slider-thumb ?

Mr_Perfect
  • 8,254
  • 11
  • 35
  • 62
Mehdi Souregi
  • 3,153
  • 5
  • 36
  • 53

1 Answers1

0

You can set/get the height of an element by using JQuery.height()

Setting height

$('your_selector').height(50);

Getting height

$('your_selector').height();

Get the parent element height of the input range and set the thumb height 80% of it

Here is working plunker

Basically, by changing width of the element you can change the height of the thumb. I just mentioned 5%. In css file of the plunker /* SET HEIGHT */ find that comment. You can change there

Mr_Perfect
  • 8,254
  • 11
  • 35
  • 62