Introduction to wildcard usage in the selector of jquery _jquery

Source: Internet
Author: User
1. Selector
(1) wildcard characters:
Copy Code code as follows:

$ ("input[id^= ' Code ']");//id all input tags starting with code
$ ("input[id$= ' Code ']");//id all input tags that end with the code
$ ("input[id*= ' Code ']");//id property contains all input labels for code

(2) According to the index selection
Copy Code code as follows:

$ ("tbody Tr:even"); Select all TR tags with an even-numbered index
$ ("tbody tr:odd"); Select all TR tags with an odd index

(3) To obtain the number of input for the next level node of Jqueryobj
Copy Code code as follows:

Jqueryobj.children ("input"). Length;

(4) Get all <a> tags under the child node of the label with class main
Copy Code code as follows:

$ (". Main > a");

(5) Select adjacent label
Copy Code code as follows:

Jqueryobj.next ("div");//Get the jqueryobj tag immediately after a div,nextall fetch all

2. Filters
Copy Code code as follows:

Not
$ ("#code input:not ([id^= ' Code '])"//id for all input tags within the code tag that do not contain IDs starting with code

3. The event
Copy Code code as follows:

Working with keyboard actions on a text box
Jqueryobj.keyup (function (event) {
var keycode = event.which;//Gets the key value that is currently pressed on the keyboard, enter 13
}

4. Tool function
Copy Code code as follows:

$ (' #someField '). Val ($ (' #someField '). Val ());//Eliminate spaces, Syntax: $.trim (value)

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.