Input Color disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Color

Description

The disabled property sets or gets whether a color picker is disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a color picker should be disabled or not
  • true - The color picker is disabled
  • false - Default. The color picker is not disabled

Return Value

A Boolean, returns true if the color picker is disabled, otherwise it returns false

The following code shows how to Disable a color picker:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="color" id="myColor"><br><br>

<button onclick="disableBtn()">Disable Color Picker</button>
<button onclick="undisableBtn()">Enable Color Picker</button>

<script>
function disableBtn() {//from w  w w .  j av a 2 s  . c om
    document.getElementById("myColor").disabled = true;
}

function undisableBtn() {
    document.getElementById("myColor").disabled = false;
}
</script>
</body>
</html>

Related Tutorials