Menu Close

Jquery :disabled selector with example

Disabled selector

In this blog, we will learn about jquery :disabled selector. The :disabled selector  is used to select all disabled form elements.



The :disabled selector is used for the HTML elements that support the disabled attribute that are <input>, <textarea>, <button>, <option>, <fieldset>, <optgroup>, <select>, and <menuitem>

If we need to select particular disabled elements, we can filter that element by its type or that element name. For example, if we need to select only the disabled button element by its name. Follow the below syntax.



In the below example there is a form, including some disabled and enabled elements. Here, we are styling all disabled form elements using the :disabled selector.


<!DOCTYPE html>
<html lang="en">
    <title>Jquery :disabled selector</title>
    <meta charset="utf-8">
    <script src=""></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
             $(":disabled").css("background-color", "#ff0000");
        .select-style {
            text-align: left;
    <div class="select-style">
        <form action="">
            Name: <input type="text" name="user"><br><br>
            E-mail: <input type="text" name="mail-id" disabled="disabled"><br><br>
            <input type="submit">
Posted in HTML, jQuery, Web Technologies

You can also read...