Jquery filter elements (2), jquery filter elements
. Add ()
Create a new object and add the elements to the matched element set.
. Add (selector)
Selector: the selector expression represented by a string. Find more elements and add them to the Matching Element Set.
$ ("P"). add ("div ")
. Add (html)
Html
Add HTML fragments to the matched element set.
$ ('Lil'). add ('<p id = "new"> new paragraph </p> ')
. Add (elements)
Elements
Add one or more elements to the Matching Element Set.
. Add (jquery object)
An existing jquery object is added to the Matching Element Set.
. Add (selector, context)
Selector
A selector expression represented by a string.
Context
Specifies the context in which the selector finds the element.
. Contents ()
Obtain the child elements of each element in the Element Set, including the text and comment nodes.
. Contents ()
This method does not accept any parameters.
$ ("P"). contents (); find all text nodes in the Section.
. Each ()
Traverses a jQuery object and executes a function for each matching element.
. Each (function (index, Element ))
Function (index, Element)
A function executed for each matching element.
$ ("Li"). each (function (index ){
Console. log (index + ":" "+ $ (this). text ()");
}); Print the index value and corresponding content of each li in a loop.
$ (Document. body). click (function (){
$ ("Div"). each (function (I ){
If (this. style. color! = "Blue "){
This. style. color = "blue ";
} Else {
This. style. color = "";
}
});
}); // When you click the document, determine whether the color of each div text is not blue. If not, it turns blue. If not, remove it.
. End ()
Terminate the latest filtering operation on the current link and return the previous status of the matched element.
. End () This method does not accept any method.
$ ("P"). find ("span" cmd.end(cmd.css ("border", "2px red solid ");