I haven't used jquery for a long time. Some functions are forgotten. Here I will look at how jquery looks for elements. Review
// Html
// Js
$ ('. Dv'). find ('ul ')-> eq (0)-> find ('lil')-> each (function (I ){
Var obj = $ (this). find ('A')-> eq (0 );
$ Em = $ ('
'); // Create an em Element
Receivem.html (I );
$ Em. insertBefore (obj); // Insert the new element to the front of the searched element.
});
This is really convenient !!!!
Question about jQuery's find Method
Find (expr)
Searches for all elements that match the specified expression. This function is a good way to find the child element of the element being processed.
All searches rely on jQuery expressions. This expression can be written using the selector syntax of the CSS1-3.
Return Value
JQuery
Parameters
Expr (String): the expression used for searching.
Example
Search for the following span element from all paragraphs. Same as $ ("p span.
HTML code:
Hello, how are you?
JQuery code:
$ ("P"). find ("span ")
Result:
[Hello]
Jquery query | jquery search element | jquery search object
# Id return value: Array # Id
Overview
Matches an element based on the given ID.
If the selector contains special characters, two slashes can be used for escape. See examples.
Parameters
IdString
Used for search, by the value specified in the element id attribute
Example
Description:
Find the element whose ID is "myDiv.
HTML code:
Id = "notMe"
Id = "myDiv"
JQuery code:
$ ("# MyDiv"); Result:
[ Id = "myDiv"
] Description:
Search for elements with special characters
HTML code:
JQuery code:
# Foo \: bar
# Foo \ [bar \]
# Foo \. barelement return value: Array Element overview match all element parameters elementString one element for search based on the given element name. The name of the tag pointing to the DOM node. Example Description: Find a DIV element. HTML code: DIV1
DIV2
SPANjQuery code: $ ("p"); Result :[ DIV1
, DIV2
]. Class return value: Array . Class overview matches elements based on the given class. The classString parameter is a class used for search. An element can have multiple classes, and can be matched as long as there is a conformity. Example Description: Find all elements of the class "myClass". HTML code: P class = "notMe"
P class = "myClass"
Span class = "myClass" jQuery code: $ (". myClass"); Result :[ P class = "myClass"
, Span class = "myClass"] selector1, selector2, selectorN return value: Array Selector1, selector2, selectorN overview combines the elements matched by each selector and returns them together. You can specify any number of selectors and merge the matched elements into a single result. The selector1Selector parameter is a valid selector2Selector and another valid selectorN (optional) Multiple valid Selector. Example Description: Find an element that matches any class. HTML code: P
P class = "myClass"
Span
P class = "notMyClass"
JQuery code: $ ("p, span, p. myClass") Result :[ P
, P class = "myClass"
, Span]