0

How to show range element value, ondragging its values should be 0-100 values when user drags that range then that values should appear like tool tip.

0<input type="range" id="range"/>100
halfer
  • 19,824
  • 17
  • 99
  • 186
Samudrala Ramu
  • 2,088
  • 1
  • 15
  • 36

2 Answers2

4

There are many possibilities to achieve this result. If you want to use the tooltip you may to take a look to Defining_Cross-Browser_Tooltips.

Instead, you may create your own tooltip with css and update its value while dragging:

document.getElementById('range').addEventListener('input', function(e) {
  //this.title = this.value;
  document.getElementsByClassName('tooltiptext')[0].textContent = this.value;
})
.tooltip {
  position: relative;
  display: inline-block;
  margin-top: 100px;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 1s;
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<form>
    <div class="tooltip">
        0<input type="range" id="range" value="0" min="0" max="100"/>100
        <span class="tooltiptext">0</span>
    </div>
</form>
gaetanoM
  • 41,594
  • 6
  • 42
  • 61
0

I made a simple JQ below.

The tool-tip (if you want it to follow and move depending on the range button as you slide left and right) is much more complicated to do, and this is not a code making site. If you try something and you don't succeed please show us that.

In the mean time, see this link. It might help you, start from here: Range Input Value Bubbles

$("input").on("change mousemove",function(){
$('output').html( $(this).val() );

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
0<input type="range" id="range" min="0" max="100"/>100
<output for="range" ></output>
halfer
  • 19,824
  • 17
  • 99
  • 186
Mihai T
  • 17,254
  • 2
  • 23
  • 32