Skip to content
Advertisement

Javascript Range – onchange event

I have code for slider:

<input id="zoomvalue" class="slider" type="range" min="30" max="100" value="100" style="width: 150px;" />``

The problem is onchange event executed when releasing mouse, but I need onchange event for every slider move. May be I don’t need input type=”range” but slider made on pure javascript/jquery.

Advertisement

Answer

You can use oninput event

var val = document.getElementById("val");
<input id="zoomvalue" class="slider" type="range" min="30" max="100" value="100" style="width: 150px;" oninput="val.innerText = this.value"/>
<span id="val"></span>
Advertisement