[jquery Filter Parentsuntil ([Expr|element][,filter])] This method is used to search for all parental elements of the current element on top of the selector until it encounters the element that matches the expression and qualification criteria

Source: Internet
Author: User

Finds all the parent elements of the current element until the matching element is encountered

If the provided jquery represents a set of DOM elements, the. Parentsuntil () method also allows us to search through the ancestor elements of all elements until we encounter an element that matches the supplied parameter. The returned jquery object contains all of the following parent elements found, but does not include the element to which the selector matches

[Expr] [, Filter]

Expr: An expression used to filter ancestor elements

Filter: A string that contains a selection expression matching element

[element] [, Filter]

element: The DOM element used to filter ancestor elements

Filter: A string that contains a selection expression matching element

Instance:

;} Html{font:15px/1.2em ' Courier New '; color: #666; width:750px;margin:25px auto;} div > p{white-space:pre-wrap;margin:15px 0;} Div>*{text-indent:8px;} . Hover{color: #FF96EC;}</style><script type= ' Text/javascript ' >    $(function(){       /*find the parent element between "Img.pic" and ". List", which is not a ". List" element node, if you do not specify a parameter, you always find the root node (HTML)*/       //$ (' img.pic '). Parentsuntil ('. List '). addclass (' hover ');       /*The first parameter can be a DOM element, and a second parameter can be passed inside the method, which can be used to limit the scope.*/        varList = document.getelementsbyclassname (' list '); $(' Img.pic '). Parentsuntil (list, ' Li '). addclass (' hover ')); });</script>

[jquery Filter Parentsuntil ([Expr|element][,filter])] This method is used to search for all parental elements of the current element on top of the selector until it encounters the element that matches the expression and qualification criteria

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.