JQuery selection and filtering method code summary. For more information about jquery learning, see. 1. Search for all qualified elements Find ()
Example: $ ('ul '). find ('lil'). addClass ('tmpexample ');
Search for all the li elements under the ul element on the page, and add the tmpExample style to the searched li element.
2. Find the sibling node of the specified ElementSiblings ()
Example: $ ('Li # tmpcarrot'). slblings (). addClass ('tmpexample ');
Find all the sibling nodes of the li element whose ID is tmpCarrot, and add the tmpExample style to the sibling node.
You can add a selector to the slblings () brackets to find the sibling node with the specified condition. For example, slblings ('. tmpClass') is a query class.
It is the sibling node of tmpClass.
3. Search for the next sibling node of the specified NodeNext ()
Example: $ ('Li # tmpbroccol'). next (). addClass ('tmpexample ');
Find the next sibling node of the li node with the ID tmpBroccoli. Add the tmpExample style to the brothers found.
4. Search for all brothers behind a specified NodeNext ()
Example: $ ('Li # tmpbroccol'). nextAll (). addClass ('tmpexample ');
Find all the sibling nodes after the li node with the ID tmpBroccoli. Add the tmpExample style to the brothers found.
5. Search for the previous sibling node of the specified NodePrev ()
Example: $ ('Li # tmpbroccol'). prev (). addClass ('tmpexample ');
Find the previous sibling node of the li node with the ID tmpBroccoli. Add the tmpExample style to the brothers found.
6. Search for all the previous sibling nodes of the specified NodePrevAll ()
Example: $ ('Li # tmpbroccol'). prevAll (). addClass ('tmpexample ');
Find all the preceding sibling nodes of the li node with the ID tmpBroccoli. Add the tmpExample style to the brothers found.
You can add a selector in the brackets of prevAll () to find the sibling node with the specified condition. For example, prevAll ('Li. tmpClass ') is to find
All the sibling nodes whose classes are tmClass before the front node.
7. Search for all qualified upper-level nodesParents ()
Example: $ ('Li # tmpcarrot'). parents ('P # tmpSelection '). addClass ('tmpexample ');
Find all the p upper-level nodes with the ID of tmpSelection for the li node whose id is tmpCarrot. Add the tmpExample sample for the searched node.
.
8. Search for upper-level nodesParent ()
Example: $ ('Li # tmpcarrot'). parent (). addClass ('tmpexample ');
Find the upper-level node of the li node whose ID is tmpCarrot. Add the tmpExample style to the node to be searched.
9. Search for subnodesChildren ()
Example: $ ('p. tmplist'). children ('h4 '). addClass ('tmpexample ');
Find the h4 tag in the subnode of p under class tmplist. Add the tmpExample style to the node to be searched.
10. Select inverse from the searched Node SetNot ()
Example: $ ('ul li '). not ('Li. tmpVegetables'). addClass ('tmpexample ');
In the found li collection, a tmpExample style is added except for the node whose class is tmpVegetables.
11. Select the segments in the node set.Slice ()
Example: $ ('ul li '). slice (). addClass ('tmpexample ');
In the found li set, select the first 1st (counting from 0, the first is actually the second) nodes, and the last four nodes for the four
Add the tmpExample style to the node.
12. add nodes to the search result setAdd ()
Example: $ ('ul # tmpAnimals li '). add ('Li # tmpBrocoli, li # tmpPepper'). addClass ('tmpexample ');
The li node set under the ul node whose id is tmpAnimals. Add the li node whose id is tmpBrocoli and the li node whose id is tmpPepper. And
Add the tmpExample style to all the li nodes in the combined set.
13. Select a specified Element in the result setEq ()
Example: $ ('ul li '). eq (10). addClass ('tmpexample ');
Add the tmpExample style to the 10th element in the li collection under ul on the page.