Open In App
Related Articles

jQuery :disabled Selector

Improve Article
Improve
Save Article
Save
Like Article
Like

The jQuery :disabled selector is used for selecting all disabled form elements. 

Syntax: 

$(":disabled")

Parameter: 

  • :disabled selector: It is used for selecting HTML elements that support the disabled attribute. i.e. button tag, input tag, outgroup tag, option tag, select tag, and textarea tag.

Example 1: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>:disabled Selector</title>
    <script src=
    </script>
    <script>
        $(document).ready(function () {
            $(":disabled").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <form action="#">
            <h1>Welcome to GeeksforGeeks!.
            </h1>
            <div>
                Text :
                <input type="text" name="text"
                       disabled="disabled">
                <br />
                <br /> Select :
                <select>
                    <option>1</option>
                    <option>2</option>
                    <option>3</option>
                    <option>4</option>
                </select>
            </div>
        </form>
    </center>
</body>
 
</html>


Output:

  

Example 2: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>:disabled Selector
    </title>
    <script src=
    </script>
    <script>
        $(document).ready(function () {
            $(":disabled").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <form action="#">
            <h1>Welcome to GeeksforGeeks!.
            </h1>
            <div>
                Text :
                <input type="text" name="text"
                       value="GeeksforGeeks">
                <br />
                <input type="submit" name="submit"
                       value="submit" disabled="disabled">
            </div>
        </form>
    </center>
</body>
 
</html>


Output: 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 10 Jul, 2023
Like Article
Save Article
Similar Reads
Related Tutorials