This article mainly introduces the wildcards in the jQuery selector. If you need them, refer to 1. Selector
(1) wildcard:
The 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
The 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.
The Code is as follows:
JqueryObj. children ("input"). length;
(4) obtain all the labels under the child node whose class is main
The Code is as follows:
$ (". Main> ");
(5) Select the adjacent tag
The Code is as follows:
JqueryObj. next ("p"); // obtain a p next to the jqueryObj tag. nextAll obtains all
2. Filter
The 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
The 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
The Code is as follows:
$ ('# SomeField '). val ($. trim ($ ('# someField '). val (); // removes spaces. Syntax: $. trim (value)