JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<button type='button' id="btnDoIt">DO IT!</button>
<div id="slider-container"></div>
<p>
<label id="rangeLabel" for="amount">Date range:</label>
<input type="text" id="amount" style="width: 300px;border: 0; color: #f6931f; font-weight: bold;" />
</p>
CSS
.ui-helper-hidden {
display: none;
}
.ui-helper-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.ui-helper-reset {
margin: 0;
padding: 0;
border: 0;
outline: 0;
line-height: 1.3;
text-decoration: none;
font-size: 100%;
list-style: none;
}
.ui-helper-clearfix:before,
.ui-helper-clearfix:after {
content: "";
display: table;
border-collapse: collapse;
}
.ui-helper-clearfix:after {
clear: both;
}
.ui-helper-zfix {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
opacity: 0;
filter: Alpha(Opacity=0); /* support: IE8 */
}
.ui-front {
z-index: 100;
}
/* Interaction Cues
----------------------------------*/
.ui-state-disabled {
cursor: default !important;
pointer-events: none;
}
/* Icons
----------------------------------*/
.ui-icon {
display: inline-block;
vertical-align: middle;
margin-top: -.25em;
position: relative;
text-indent: -99999px;
overflow: hidden;
background-repeat: no-repeat;
}
.ui-widget-icon-block {
left: 50%;
margin-left: -8px;
display: block;
}
/* Misc visuals
----------------------------------*/
/* Overlays */
.ui-widget-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.ui-accordion .ui-accordion-header {
display: block;
cursor: pointer;
position: relative;
margin: 2px 0 0 0;
padding: .5em .5em .5em .7em;
font-size: 100%;
}
.ui-accordion .ui-accordion-content {
padding: 1em 2.2em;
border-top: 0;
overflow: auto;
}
.ui-autocomplete {
position: absolute;
top: 0;
left: 0;
cursor: default;
}
.ui-button {
padding: .4em 1em;
display: inline-block;
position: relative;
line-height: normal;
margin-right: .1em;
cursor: pointer;
vertical-align: middle;
text-align: center;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
/* Support: IE <= 11 */
overflow:...
JavaScript
$(document).on('click', '#btnDoIt', function () {
var dates = '["1999-01-05T00:00:00","2001-04-01T00:00:00","2003-03-21T00:00:00","2006-12-01T00:00:00","2007-08-31T00:00:00","2007-10-24T00:00:00","2007-12-14T00:00:00","2007-12-23T00:00:00","2008-02-18T00:00:00","2008-03-26T00:00:00","2008-06-23T00:00:00","2008-10-09T00:00:00","2009-02-01T00:00:00","2009-07-14T00:00:00","2009-07-16T00:00:00","2009-08-18T00:00:00","2010-03-16T00:00:00","2011-03-11T00:00:00","2011-09-28T00:00:00","2011-11-11T00:00:00","2011-12-23T00:00:00","2012-03-09T00:00:00","2012-08-22T00:00:00","2012-09-17T00:00:00","2013-05-23T00:00:00","2014-01-16T00:00:00","2014-03-24T00:00:00","2014-11-26T00:00:00","2015-06-17T00:00:00","2015-07-08T00:00:00","2015-09-03T00:00:00","2015-11-27T00:00:00","2016-08-17T00:00:00","2016-09-01T00:00:00","2016-11-14T00:00:00","2017-01-26T00:00:00","2019-08-19T00:00:00"]';
loadRange(dates);
});
function loadRange (dates) {
dates = $.parseJSON(dates);
'use strict';
var convertedArray = [];
for (var index = 0; index < dates.length; ++index) {
var converted;
if (index === 0) {
converted = (new Date(dates[index]).getTime() - 86400000) / 1000;
} else {
converted = (new Date(dates[index]).getTime() + 86400000) / 1000;
}
convertedArray.push(converted);
}
var min = new Date(convertedArray[0] * 1000).toISOString().slice(0, 10);
var max = new Date(convertedArray[convertedArray.length - 1] * 1000).toISOString().slice(0, 10);
var minDate = min;
var maxDate = max;
$("#slider-container").slider({
range: true,
min: convertedArray[0],
max: convertedArray[convertedArray.length - 1],
step: 864,
values: convertedArray,
slide: function (event, ui) {
var min = new Date(ui.values[0] * 1000).toISOString().slice(0, 10);
var max = new Date(ui.values[ui.values.length - 1] * 1000).toISOString().slice(0, 10);
$("#amount").val(min + " - " + max);
minDate = min;
maxDate =...