Attribute Filters)The content is the attributes in the HTML element, such as name, ID, class, but not the value. It refers to the attribute itself.ArticleI will talk about my understanding of this selector series. One of the reasons is that it is easy to understand its meaning and remember its meaning, and the other is "Mixed Face". Even if you cannot remember it, in the future, you can quickly search for and apply APIs.
It includes the following selectors:
- [Attribute]
- [Attribute = value]
- [Attribute! = Value]
- [Attribute ^ = value]
- [Attribute $ = value]
- [Attribute * = value]
- [Attributefilter1] [attributefilter2] [attributefiltern]
[Attribute]
Usage:$ ("Div [ID]");
Note: elements that contain the given attributes are matched. In jquery 1.3, the leading @ symbol has been abolished! To be compatible with the latest version, simply remove the @ symbol. yes, the @ symbol must be removed from the new version. I believe that old versions of shoes will become used to this change. in this example, all Div labels with the "ID" attribute are selected.
[Attribute = value]
Usage:$ ("Input [name = 'newsletter ']"). ATTR ("checked", true );
Description: matching a given attribute is an element of a specific value. In this example, all the name attributes are selected as the input element of newsletter.
[Attribute! = Value]
Usage:$ ("Input [name! = 'Newsletter'] "). ATTR (" checked ", true );
Description: It matches all elements that do not contain specified attributes or that do not equal to a specific value. this selector is equivalent to: Not ([ATTR = value]). to match an element that contains a specific attribute but is not equal to a specific value, use [ATTR]: not ([ATTR = value]). well, what we saw earlier: Not came in handy.
[Attribute ^ = value]
Usage:$ ("Input [name ^ = 'News']");
Note: matching a given attribute is an element starting with some values. Well, we have seen these symbols similar to regular matching. Can you forget them now ?!
[Attribute $ = value]
Usage:$ ("Input [name $ = 'Letter ']");
Note: matching a given attribute is an element ending with some values.
[Attribute * = value]
Usage:$ ("Input [name * = 'man']");
Note: matching a given attribute is an element that contains certain values.
[Attributefilter1] [attributefilter2] [attributefiltern]
Usage:$ ("Input [ID] [name $ = 'man']");
Note: The composite attribute selector is used when multiple conditions must be met at the same time. it is a combination, which is commonly used in actual use. in this example, all elements that contain the ID attribute and whose name attribute ends with man are selected.
attribute filters learning shows that jquery's selector usage is subtle and meticulous. it reminds me of the space ship explosion or something caused by a decimal point. it is a bit sensational, but after we use a lot, it will naturally be easy to separate the differences.