JSFiddle - React, Tailwind, and code Playground
by John Smith
HTML
<script src="http://ionden.com/a/plugins/ion.rangeSlider/static/js/ion-rangeSlider/ion.rangeSlider.js"></script>
<link rel="stylesheet" href="http://ionden.com/a/plugins/ion.rangeSlider/static/css/ion.rangeSlider.css">
<link rel="stylesheet" href="http://ionden.com/a/plugins/ion.rangeSlider/static/css/ion.rangeSlider.skinHTML5.css">
<div class="range-slider">
<input type="text" class="js-range-slider" value="" />
</div>
<div class="extra-controls">
<input id="inVal" type="text" class="js-input" value="0" />
</div>
<table class="tdStyle">
<tbody>
<tr>
<td id="value1t">21</td>
</tr>
</tbody>
</table>
CSS
html {
height: 100%;
}
body {
height: 100%;
overflow: hidden;
margin: 40px 15px;
font-family: Arial, sans-serif;
font-size: 12px;
}
.range-slider {
position: relative;
height: 80px;
}
.extra-controls {
position: relative;
border-top: 3px solid #000;
padding: 10px 0 0;
}
.tdStyle {
text-align: center;
margin-top: 20px;
}
JavaScript
var $range = $(".js-range-slider"),
$input = $(".js-input"),
instance,
min = 0,
max = 100;
$range.ionRangeSlider({
type: "single",
min: min,
max: max,
onStart: function (data) {
$input.prop("value", data.from);
},
onChange: function (data) {
$input.prop("value", data.from);
}
});
instance = $range.data("ionRangeSlider");
$input.on("change keyup", function () {
var val = $(this).prop("value");
// validate
if (val < min) {
val = min;
} else if (val > max) {
val = max;
}
instance.update({
from: val
});
});
var val = document.querySelector('#value1t').innerHTML;
document.querySelector('#inVal').value = val;