Home > Article > Web Front-end > Example of usage of [attribute!=value] selector in jQuery_jquery
The example in this article describes the usage of the [attribute!=value] selector in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
This selector matches all elements that do not contain the specified attribute, or that have an attribute that is not equal to a specific value.
This selector is equivalent to: not[([attr=value]).
To match elements that have a specific attribute but are not equal to a specific value, use [attr]:not([attr=value])
Grammar structure:
Example code:
Example 1:
The above code can set the text color in the li element whose id attribute value is not equal to second or does not have an id attribute value to blue.
Example 2:
From the above code, you can see how when the code contains "[" or "]", it must be enclosed in quotation marks, otherwise it will cause a matching error.
I hope this article will be helpful to everyone’s jQuery programming.