Jquery filter elements (2), jquery filter elements

Source: Internet
Author: User

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

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.