Javascript Reference - HTML DOM Link disabled Property








The disabled property sets or gets whether the linked document is disabled.

Browser Support

disabled Yes Yes Yes Yes Yes

Syntax

Return the disabled property.

var v = linkObject.disabled 

Set the disabled property.

linkObject.disabled=true|false

Property Values

Value Description
true|false Disable or enable the linked document
  • true - The linked document is disabled
  • false - The linked document is not disabled




Return Value

A Boolean type value, true if the linked document is disabled, otherwise false.

Example

The following code shows how to get if the linked document is disabled.


<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="styles.css">
</head><!--   w  w  w.  j  a  v a2 s.c o m-->
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myLink").disabled;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to disable the linked document.


<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="styles.css">
</head><!--from   w  ww  . ja va  2s.c  o  m-->
<body>
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myLink").disabled = true;
}
</script>

</body>
</html>

The code above is rendered as follows: