Reputation: 1387
I am working on a page using only html5 and jquery, and I have a range input as follows:
<input id="mySlider" type="range" class="test" min="2" max="32" step="2" value="10" />
Is there any way to dynamically alter the min of this input? I've tried referencing / setting by using getElementByID and trying to access the min attribute (the same way you could do for .value), but this doesn't appear to work. Thanks!
Upvotes: 2
Views: 3890
Reputation: 10771
How about accessing the attribute directly?
$("#mySlider").attr("min", 4);
See http://api.jquery.com/attr/
Upvotes: 0
Reputation: 348972
I have successfully changed the value in many ways, including:
document.getElementById('mySlider').min = 5; // Example: min value of 5
$('#mySlider').prop('min', 5); //jQuery method
Make sure that you have spelled document.getElementById
correctly, using a lowercase d
.
Go try this fiddle: http://jsfiddle.net/8W7FF/
Upvotes: 3