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);