@Renan has already posted a good solution (and already took my +1), I will leave here a similar alternative, with a few small differences in the syntax and methods used:
<input type="range" name="vol" value="0" min="0" max="100"
oninput="display.value=value" onchange="display.value=value">
<input type="text" id="display" value="0" readonly>
- The estate
oninput
calls a JS function, and is usually "Realtime", but is less compatible than using onchange
(for example, in IE does not work).
onchange
works in more browsers, but it is not at all that updates in Altime, so we use both simultaneously.
Of curiosity, you can make it work in "two ways". Editing the text field, the slider accompanies. Moving the slider, the text field accompanies:
<input type="range" id="vol" name="vol" value="0" min="0" max="100"
oninput="display.value=value" onchange="display.value=value">
<input type="text" id="display" value="0"
oninput="vol.value=value" onchange="vol.value=value">
No one sleeps !!!
– MagicHat
@Magichat neither sleeps nor has social life kkkk
– Bacco
I wanted to do with data-Attributes, but I was disappointed that I could not use
attr(value)
in css. It would be more elegant something without Javascript, but as the property is relatively new we have to give a discount.– Renan Gomes
@Renan comes to think that it should be an own html option to display the value.
– Bacco
@The worst thing is that attr value works for the initial value, but does not update after it changes.
– Bacco