The disabled
property disables or enables a slider control.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = rangeObject.disabled
Set the disabled property.
rangeObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a slider control
|
A Boolean type value, true if the slider control is disabled, otherwise false.
The following code shows how to check if a slider control is disabled or not.
<!DOCTYPE html>
<html>
<body>
<input type="range" id="myRange" disabled>
<button onclick="myFunction()">test</button>
<!-- w w w. j a v a 2 s .co m-->
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myRange").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a slider control.
<!DOCTYPE html>
<html>
<body>
<!--from www.ja v a 2s . co m-->
<input type="range" id="myRange"><br><br>
<button onclick="disableBtn()">Disable Slider Control</button>
<button onclick="enableBtn()">Enable Slider Control</button>
<script>
function disableBtn() {
document.getElementById("myRange").disabled = true;
}
function enableBtn() {
document.getElementById("myRange").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: