CSS selector of jQuery-greater than sign Mode

Source: Internet
Author: User

DocumentThe CSS selector syntax contains a greater sign and is also referenced in the jQuery selector syntax. I have never specifically figured out the difference between this selector and the space selector. Here is a small example to learn about it, because jQuery and CSS have similar syntax in this part, therefore, jQuery is directly used to explain the problem, which is more intuitive.

  Let's take a look at the example. The structure is very simple:

Reference content is as follows:
<Div id = "test"> <div> a </div> <div> B </div> <div> c </div> <div> <div> d </div> <div> e </div>, we can execute the following two statements:
Alert ($ ('# test> div'). length );
Alert ($ ('# test div'). length );

  The first statement uses a greater than the number selector to search for the div element in the first child element of # test. In this example, the result is 2.

  The second statement uses a space selector to search for the div element in all sub-elements of # test. In this example, 7 is returned, it includes two subelements of the first level and five subelements of the second level.

  Is that simple, do you understand? You are welcome to continue reading other articles from the Institute.

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.