jquery Selector Summary

Source: Internet
Author: User
Tags filter object reference return string wrapper

A. What is a jquery selector
In DOM programming, we can only use finite functions to get DOM objects based on IDs or tagname.
In jquery it's completely different, and jquery provides an unusually powerful selector to help us get the objects on the page and return the objects in the form of a jquery wrapper set.
First look at what selectors are:
Get jquery wrapper set var Jqueryobject = $ ("#testDiv") based on ID;
In the example above, the ID selector is used, the DOM object with ID Testdiv is selected and placed in the jquery wrapper set, and finally returned in the form of the jquery wrapper set. The $ symbol represents a reference to a jquery object in jquery, and "JQuery" is a core object that contains the following methods:
JQuery (expression, context)
Returns:jquery
This function receives a string of CSS selectors and then uses this string to match a set of elements.
This function accepts a string containing a CSS selector which are then used to match a set of elements.
JQuery (HTML, ownerdocument)
Returns:jquery
Dynamically creates a DOM element from an HTML raw string.
The Create DOM elements on-the-fly from the provided String of Raw HTML.
JQuery (elements)
Returns:jquery
Encapsulates one or more DOM objects in jquery function (that is, encapsulated as a jquery wrapper set)
Wrap jQuery functionality around a single or multiple DOM Element (s).
JQuery (callback)
Returns:jquery
$ (document). Shorthand for Ready ()
A shorthand for $ (document). Ready ().
It is selected from the official jquery manual. The type of returns is jquery, which means that the jquery wrapper set is returned. The first method has some problems, the official interface is a CSS selector, but in practice this method does not just support CSS selectors, Instead of all jquery-supported selectors, some are even jquery's custom selectors (selectors that do not exist in CSS standards). In order to make it clearer, I will revise the method as follows:
JQuery (selector, context)
Returns:jquery Packing Set
The matching object is selected according to the selector and returned in the form of a jquery wrapper set. The context can be either a collection of Dom objects or a jquery wrapper set, and the incoming means that you want to select a matching object from within, and not pass in the range as the document object (that is, all of the page objects).
The above method is the core method used by our selector. You can use "$" instead of jquery to make the syntax more concise, for example, the following two sentences have the same effect:
Get jquery wrapper set var Jqueryobject = $ ("#testDiv") based on ID; $ is a reference to a jquery object: var jqueryobject = jquery ("#testDiv");
Next let's learn the jquery selector systematically.

Two. jquery Selector full Solution
In layman's terms, the selector selector is "A string that represents a particular semantic." You can select a different DOM object and return it as a jquery wrapper set as long as you pass the selector string into the above method.
But how to classify the jquery selector makes me puzzled. Because the classification of the book is different from the official jquery classification. Finally I decided to be practical, not to understand the CSS3 selector standards, and according to the jquery official classification of the explanation.
The jquery selector supports the CSS3 selector standard. The following is the latest CSS3 selector standard for the consortium:
http://www.w3.org/TR/css3-selectors/
The selectors in the standard can be used in jquery.
The jquery selector is mainly divided into "select" and "filter" according to function. and is used in conjunction with. You can use a combination of a selector string at the same time. The main difference is that the filter action selector specifies that the condition is filtered from the previous match, and the filter selector can be used separately to indicate filtering from all "*". Like what:
$ (": [title]")
Equivalent to:

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.