HTML | DOM Select disabled Property

The DOM Select disabled Property in HTML DOM is used to set or return whether a drop-down list should be disabled. A disabled element is un-clickable or unusable and is usually rendered grey color by default in Browser. This Property is used to reflect the HTML disabled attribute.

Syntax:

  • It returns the disabled property.
    selectObject.disabled
  • It is used to set the disabled property.
    selectObject.disabled = true|false

Property Values:

  • true: It specify that the drop-down list would be disabled.
  • false: It specify that the drop-down list would not be disabled.

Return Value: It returns a boolean value which represents that the dropdown list would be disabled or not.

Example: This Example returns a disabled Property,

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Select disabled Property in HTML
    </title>
    <style>
        h1 {
            color: green;
        }
          
        h2 {
            font-family: Impact;
        }
          
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
  
    <h1
    GeeksforGeeks 
</h1>
    <h2
    Select disabled Property 
</h2>
  
    <select name="Courses Titles"
            id="myCourses" 
            disabled>
        <option value="C++">c++</option>
        <option value="Placement">Placement</option>
        <option value="Java">Java</option>
        <option value="Python">Python</option>
    </select>
  
    <p>
        To return a disabled course from the
      dropdown list, double-click the "Select" button.
    </p>
  
    <button ondblclick="My_list()">
        Select
    </button>
    <p id="sudo" 
       style="font-size:24px;
              color:green">
  </p>
    <script>
        function My_list() {
            var g = document.getElementById(
                "myCourses").disabled;
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before Clicking On Button:

After Clickcing On Button:

Example-2: This Example sets the disabled Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Select disabled Property in HTML
    </title>
    <style>
        h1 {
            color: green;
        }
          
        h2 {
            font-family: Impact;
        }
          
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
  
    <h1
    GeeksforGeeks 
</h1>
    <h2
    Select disabled Property 
</h2>
  
    <select name="Courses Titles" 
            id="myCourses" 
            disabled>
        <option value="C++">c++</option>
        <option value="Placement">Placement</option>
        <option value="Java">Java</option>
        <option value="Python">Python</option>
    </select>
  
    <p>
        To set a disabled course from the dropdown 
      list, double-click the "Select" button.
    </p>
  
    <button ondblclick="My_list()">
        Select
    </button>
    <p id="sudo"
       style="font-size:24px;
              color:green">
  </p>
    <script>
        function My_list() {
            var g = document.getElementById(
                "myCourses").disabled = "false";
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers:

  • Google Chrome
  • Mozilla Firefox
  • Edge
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.