jquery Notes: Filter Eq,first,last,filter,is,has, not, children,closest, nextuntil,parents,parentsuntil ...

Source: Internet
Author: User
eq (index|-index)

Gets the nth jquery object in the current chain operation, and returns the JQuery object, when the argument is greater than or equal to 0 o'clock for the forward selection, for example, 0 represents the first, and 1 represents the second. Select the reverse when the argument is negative, for example-1 is the penultimate first

index Integer V1.1.2

An integer that indicates that the element is based on the position of 0, which is the position of the element from 0. -index Integer V1.4

An integer that indicates the position of the element, starting at the bottom of the last element in the collection. (-1 counts)

$ ("P"). EQ (1)
A ()
$ (' Li ').
Last ()
$ (' Li '). Last ()
filter (EXPR|OBJ|ELE|FN)

Filters out the collection of elements that match the specified expression.

This method is used to narrow the range of matches. Comma-delimited multiple expressions expr StringV1.0

A string value containing a selector expression to match the collection of the current element. JQuery Object objectV1.0

An existing jquery object to match the current element. element ExpressionV1.4

A DOM element that is used to match elements. Function (index) FunctionV1.4

A function is used as a collection of test elements. It accepts a parameter index, which is the index of the element in the jquery collection. In function, this refers to the current DOM element.

$ ("P"). Filter (". Selected")
$ ("P"). Filter (". selected,: a")
$ ("P"). Filter (function (index) {return
  $ (' ol ', this). length = = 0;
});
is (EXPR|OBJ|ELE|FN)

Detects a collection of matching elements based on a selector, DOM element, or JQuery object, and returns true if at least one of the elements conforms to the given expression.

Returns ' false ' if there is no element conformance, or if the expression is invalid. ' Note: ' In jquery 1.3, all expressions are supported. In previous versions, if a complex expression was provided, such as a hierarchy selector (such as +, ~, >), it would always return true expr StringV1.0

A string value containing a selector expression to match the collection of the current element. JQuery Object objectV1.6

An existing jquery object to match the current element. element ExpressionV1.6

A DOM element that is used to match elements. Function (index) FunctionV1.6

A function is used as a collection of test elements. It accepts a parameter index, which is the index of the element in the jquery collection. In function, this refers to the current DOM element.

$ ("input[type= ' checkbox ']"). Parent (). is ("form")
has (Expr|ele)

Preserves elements that contain specific descendants, removing elements that do not contain the specified descendants.

The. has () method will re-create a matching set of objects from the given jquery object. The supplied selector tests the descendants of the original objects, and the objects that contain the matching descendants are preserved.

$ (' Li '). has (' ul '). CSS (' background-color ', ' red ');
Not (EXPR|ELE|FN)Deletes the element that matches the specified expression from the collection of matching elements

$ ("P"). Not ($ ("#selected") [0])  deletes an element with the ID of a select from the P element
children ([expr])

Gets a collection of elements that contain all the child elements of each element in a matching set of elements.

You can filter the matched child elements through an optional expression. Note: parents () will look for all ancestral elements, while children () takes into account only child elements, regardless of all descendant elements.

$ ("div"). Children (". Selected")
closest (expr|object|element)Closest first checks whether the current element matches, and returns the element itself if it matches. If it does not match, look up the parent element, one level up, until you find the element that matches the selector. If nothing is found, an empty jquery object is returned.

$ ("Li:first"). Closest (["ul", "body"]);
Nextuntil ([Exp|ele][,fil])
$ (' #term-2 '). Nextuntil (' DT '). CSS (' background-color ', ' red ');
parents ([expr])
$ ("span"). Parents ()
$ ("span"). Parents ("P")
Parentsuntil ([Expr|element][,filter])
$ (' li.item-a '). Parentsuntil ('. Level-1 ')
    . css (' background-color ', ' red ');
Prevuntil ([Exp|ele][,fil]) siblings ([expr])

Gets a collection of elements that contain all the unique sibling elements of each element in a matching set of elements. You can filter with an optional expression. Add (Expr|ele|html|obj[,con]) adds an element that matches the expression to the jquery object. This function can be used to connect the result sets of elements that match two different expressions.

$ ("P"). Add ("span") adds a new element to a matching set of elements, and the new element matches the given expression.
contents ()Finds all child nodes within a matching element, including text nodes. If the element is an IFRAME, find the contents of the document

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.