Constantine Constantine - 2 years ago 123
jQuery Question

HTML5 reset slider to min position

What I am trying to do is get the slider to reset it's value and animation position to zero but I can't find how.


http://jsfiddle.net/v4gNL/1359/


HTML5:

<body>

<span>
<select id="selectSymptom">
<option value="option" >Select Option</option>
<option value="option1" >Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
<option value="option5">Option 5</option>
<option value="option6">Option 6</option>

</select>
</span>
<span style='display:none;' id="slider"> <input type="range" min="0" max="10" value="0" step="0.1" id="rangeValue"><label id="text">0</label></span>

</body>


JQuery:

$('#selectSymptom').on('change', function() {
$("#text").text(0);

var selected = $(this).find('option:selected').val();
$("#slider").show();
});
$("#rangeValue").mousemove(function() {
$("#text").text($("#rangeValue").val());
});

Answer Source

Simply set it's value to 0 in the change event of the dropdown

  $('#rangeValue').val(0);

http://jsfiddle.net/v4gNL/1361/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download