JQuery (expression, [context]), $ (jQuery) parameter

Source: Internet
Author: User

JQuery (expression, [context]), $ (jQuery) parameter
JQuery (expression,[Context]) Return Value: jQuery Overview

This function receives a string containing the CSS selector and uses this string to match a group of elements.

JQuery's core functions are implemented through this function. Everything in jQuery is based on this function, or is using this function in some way. The most basic usage of this function is to pass an expression (usually composed of CSS selectors) to it, and then find all matching elements based on this expression.

By default, if the context parameter is not specified, $ () searches for DOM elements in the current HTML document. If the context parameter is specified, such as a DOM element set or jQuery object, then it will be searched in this context. After jQuery 1.3.2, the returned element order is equivalent to the order in which the elements appear in the context.

Refer to the selector section in the document to obtain more information about the CSS syntax used for the expression parameter.

Parameters ExpressionString

String to be searched

Context(Optional)Element, jQuery

Used as the DOM Element Set, document, or jQuery object to be searched.

Example description:

Find all p elements, and these elements must be child elements of the div element.

HTML code:

one

two

three

JQuery code:
$("div > p");
Result:
[ 

two

]
Description:

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

JQuery code:
$("input:radio", document.forms[0]);
Description:

Search for all div elements in an XML document returned by AJAX.

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

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.