Is there any way to recreate the input range using plain js (without using jQuery).
Expected Result
<input type="range">
My current work
function slide(e,t) {
t.style.paddingLeft = e.clientX-t.offsetLeft+'px';
}
div {
width : 400px;
height: 10px;
background-color: #aaa;
margin: 20px 0;
box-sizing: border-box;
}
div>div {
height: 10px;
width : 10px;
background-color: black;
border: 1px solid black;
transform: translate(-10%, -10%);
}
<div onclick="slide(event,this)" onmouseover="slide(event,this)">
<div></div>
</div>
Problem
In an actual input range the thumb only moves when we are dragging it but here it moves when we are hovering over it. is there any way to move it when we are only dragging it ?. Even in an example with many sliders in the same page.
Any help in rephrasing the question is highly appreciated.
<input type="range">already, so there's no need to recreate it in JavaScript. Heck, even Internet Explorer 10 supports it...touch*andmousemoveevents, there are much better exercises than arangeinput, imo. Have you considered starting off with something simpler, such as a<canvas>painting demo?