Sharp jquery Learning Notes

Source: Internet
Author: User

1.$ ("#tt") gets always a jquery object, so to determine if there is an object on the page cannot be like JS

if($ ("#tt")) {}
View Code

But by:

if ($ ("#tt"0) {}
View Code

PS: When there is no element in the page ID TT, jquery will not error, and JS will error

2. jquery Layer Selector $ ("ancestor descendant") and $ ("Parent>child")

 is  is <em>really <strong>very</strong></em> important.</div>
View Code

Like a family three generations together, Grandpa, Father and you, so grandpa's son element is your father, while your father is also the descendants of Grandpa elements, and you are only the descendants of Grandpa elements.

Summary: Descendant elements include child elements, which refer to the father's first generation.

3. Types of jquery Selectors

3.1 Basic Selector

3.2 Hierarchy Selector

3.3 Filter Selector

3.3.1 Basic Filter Selector

$ ("Div:first") Select the first div;$ ("Div:last") Select the Last div;$ ("Input:not (. MyClass)") Select the MyClass ("input;$") of the class that is not Input:even Select an even-numbered index

Input; $ ("input:odd") Select input;$ with an odd index ("Input:eq (1)") to select an INPUT element with an index equal to 1, and $ ("INPUT:GT (1)") to select an index greater than 1input;$ ("input:lt (1)"

Select input with index less than 1

3.4 form Selector

  

Sharp jquery Learning Notes

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.