1. Selector
(1) wildcard:
Copy codeThe Code is as follows:
$ ("Input [id ^ = 'code']"); // all input tags whose id attribute starts with code
$ ("Input [id $ = 'code']"); // all input tags whose id attribute ends with code
$ ("Input [id * = 'code']"); // all input tags whose id attribute contains code
(2) Select an index
Copy codeThe Code is as follows:
$ ("Tbody tr: even"); // select all tr tags with an even Index
$ ("Tbody tr: odd"); // select all tr tags whose indexes are odd.
(3) obtain the number of inputs of the next level node of jqueryObj.
Copy codeThe Code is as follows:
JqueryObj. children ("input"). length;
(4) obtain all the <a> labels under the child node with the class as main
Copy codeThe Code is as follows:
$ (". Main> ");
(5) Select the adjacent tag
Copy codeThe Code is as follows:
JqueryObj. next ("div"); // obtain a div next to the jqueryObj tag. nextAll obtains all
2. Filter
Copy codeThe Code is as follows:
// Not
$ ("# Code input: not ([id ^ = 'code'])"); // The id is a code tag that does not contain all input tags whose id starts with code.
3. Events
Copy codeThe Code is as follows:
// Process keyboard operations on the text box
JqueryObj. keyup (function (event ){
Var keyCode = event. which; // obtain the key value of the currently pressed keyboard. The enter key is 13
}
4. Tool Functions
Copy codeThe Code is as follows:
$ ('# SomeField '). val ($. trim ($ ('# someField '). val (); // removes spaces. Syntax: $. trim (value)