jQuery(expression, context) → jQuery
- The core functionality of jQuery centers around this function. Everything in jQuery is based upon this, or uses this in some way. The most basic use of this function is to pass in an expression (usually consisting of CSS), which then finds all matching elements. By default, if no context is specified, $() looks for DOM elements within the context of the current HTML document. If you do specify a context, such as a DOM element or jQuery object, the expression will be matched against the contents of that context. See <a href='Selectors'>Selectors</a> for the allowed CSS syntax for expressions.
- Finds all p elements that are children of a div element.
- $("div > p").css("border", "1px solid gray");
- <p>one</p> <div><p>two</p></div> <p>three</p>
- Finds all inputs of type radio within the first form in the document.
- $("input:radio", document.forms[0]);
- Finds all div elements within an XML document from an AJAX response.
- $("div", xml.responseXML);
No comments:
Post a Comment