How to reverse the direction in HTML5 range input?
This is simply do with CSS and pure JavaScript. I hope this snippet will help you.
CSS & HTML
input{
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
Max<input type="range" min="0" max='5' value="0" step="1" onmousemove="document.getElementById('Range_Value').innerHTML=this.value" onchange="document.getElementById('Range_Value').innerHTML=this.value">Min
<h3>Value: <span id="Range_Value">0</span></h3>
This might do the trick: setting the direction of the input to be right to left on the CSS
#reversedRange {
direction: rtl
}
See sample code below:
PS the javascript/jquery code is only to illustrate the values changing and it's not needed. Only the CSS and the id
attribute on the input
element
Updated: based on comments by @MCTaylor17 (thanks)
$(function() {
$("#rangeValue").text($("#reversedRange").val());
$("#reversedRange").on('change input', function() {
$("#rangeValue").text($(this).val());
});
});
#reversedRange {
direction: rtl
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Max<input type="range" min="0" max='5' value="0" step="1" id="reversedRange">Min
<div>value: <span id="rangeValue"></span>
</div>