jQuery > Selectors

element[attribute!='value' - Attribute not equals in jQuery

How to select elements whose attribute value doesn't contain certain characters


To find out all elements whose specific attribute value doesn't contain certain characters we can use "!=" operator.

    <input id="txtName" type="text" data-id="txt Name" />
    <input id="FirstNameF" type="text" data-id="name txt" />
    <input type="button" value="Button" id="btnTest" />

    <script>
        $(function () {
            $("input[type!='text']").css("border", "5px solid green");
        });
    </script>

Above jQuery code snippet select the third element as only that element type is not "text" and this element get applied with border 5px solid and green.

Output

Attribute not equal to

 Views: 1786 | Post Order: 21



Write for us