You need to use the change event. And take the value of the slider like this ($(this).val() , not passing as a parameter. This is an update to the rectangle when you are finished to select the value.
.background-color { width: 500px; height: 500px; background: red; opacity: .5; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form> <label>Color Opacity</label> <input type="range" name="bgopacity" id="bgopacity" value="50" min="0" max="100" step="1" onchange="rangevalue.value=value"> <output id="rangevalue">50</output> </form> <div class="background-color"></div>
You can use the input event to update real-time . This is updated when the value changes.
.background-color { width: 500px; height: 500px; background: red; opacity: .5; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form> <label>Color Opacity</label> <input type="range" name="bgopacity" id="bgopacity" value="50" min="0" max="100" step="1" onchange="rangevalue.value=value"> <output id="rangevalue">50</output> </form> <div class="background-color"></div>
source share