jquery (expression, [context]), $ (that is, jquery), question of the number of parameters

Source: Internet
Author: User

JQuery (expression, [Context]) return value: jquery overview

This function receives a string that includes a CSS selector and then uses that string to match a set of elements.

The core functionality of JQuery is achieved through this function. Everything in jquery is based on this function, or the function is used in some way. The main use of this function is to pass an expression (usually composed of a CSS selector) to it, and then find all the matching elements based on the expression.

By default, if a context parameter is not specified, $ () looks for the DOM element in the current HTML document; If a context parameter is specified, such as a DOM element set or a JQuery object, it will be found in this context. After jquery 1.3.2, the order of elements returned is equivalent to the order in which they appear in the context.

The selector section of the reference document gets many other information about the CSS syntax for expression parameters.

Number of references expressionString

The string to find

context (optional) Element, JQuery

As a set of DOM elements, a document, or a JQuery object to be found.

Demo sample Descriptive narrative:

All P elements are found, and the elements must be child elements of the DIV element.

HTML Code:
<p>one</p> <div><p>two</p></div> <p>three</p>
JQuery Code:
$("div > p");
Results:
[ <p>two</p> ]
Descriptive narrative:

In the first form of the document, look for all the radio buttons (that is, the input element with the type value radio).

JQuery Code:
$("input:radio", document.forms[0]);
Descriptive narrative:

In an XML document returned by AJAX, find the entire DIV element.

JQuery Code:
$("div", xml.responseXML);

jquery (expression, [context]), $ (that is, jquery), question of the number of parameters

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.