Introduction to using wildcards in jQuery Selector

Source: Internet
Author: User
Tags code tag

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.