Application of Selector
JQuery should be applied on the basis of the selector. We can search for elements by element id, name, tagname, etc. All we need to do is to pass a so-called seletor to the $ () function, haha, part of my work in learning jQuery is to learn how to build a reasonable seletor to find the elements I need;
Seletor construction:
Basic:
Locate by element id, class name, and element name. If you are familiar with css, you can understand the seletor rules of jQuery. These rules are also used when css is defined.
# Id: Set the tagname of A class element for a single element. class (element name;
Fortunately, we can use commas (,) to randomly select multiple elements;:-DLevel:
1. We often need to obtain sub-elements under an element (divided into all, directly two types)
A B gets all B elements under a, And a> B gets B directly sub-elements under.
2. We also often obtain sibling elements of the same level of elements, such as: elements that need to be next to an element, or all sibling elements behind an element;
It is also simple: prev + next gets the next element next to prev, prev ~ Sibling obtains all peer elements after prev;
Set selection:
When selecting an approximate set through selector, we may need some elements, so we have selector for further operations;
: First,: last: not removes some elements: eq,: gt,: lt equal to, greater than, less than a set of elements of an index; you can also directly obtain the set with an odd number (: odd) or an even number (: event ).
Further content filtering:
We can also filter the content of a dom object, including whether some text is contained, whether an element is contained, and whether it is null. It contains all the operations we need;
: Contains the specified text. empty does not contain any sub-content.
: Has contains an element: parent contains sub-content
Visibility:
Use: hidden to find all hidden elements, and visible to find the displayed elements.
Filter attributes:
We can match the elements that contain an attribute, include an attribute and match the value, and add multiple conditions;
[ASD] contains an attribute. [ASD = value] matches an element with an attribute of the target ID and its value is val. There are also several matching methods, similar to the matching method of a regular expression:
[Recognition service! = Value] is not equal to the value starting with val, and the value ending with val.
[ASD * = val] the attribute value contains the val value;
Matching of form elements:
: Text: radio: checkbox ....
: Enable,: disabled,: checked (radio, checkbox selected),: selected; (select selected)