Div |
---|
class | Wiki Markup |
---|
{div:class=api-page | }
h1. fluid.findAncestor(element, test) Section |
---|
Column |
---|
|
|
Finds the nearest ancestor of the element that passes the test.
Code Block |
---|
javascript | javascript | bgColor | white |
---|
borderStyle | none |
---|
{section}
{column:width=70%}
Finds the nearest ancestor of the element that passes the test.
{code:javascript|borderStyle=none|bgColor=white}
fluid.findAncestor(element, test);
File name:
{code}
*File name:* {{Fluid.js
Parameters
Span |
---|
class | }}
h2. Parameters
{span:class=borderless-table
element
| }
|*{{element}}*| (Element) DOM
element test
| element |
|*{{test}}*| (Function) A function which takes an element as a parameter and returns true or false for some test
. Return Value
Span |
---|
|
Element | the nearest ancestor that passes the test |
|
Column |
---|
|
Example
Code Block |
---|
javascript | javascript | . |
{span}
h2. Return Value
{span:class=borderless-table}
|*Element*| the nearest ancestor that passes the test |
{span}
{column}
{column:width=5%}
{column}
{column}
h3. See Also
{column}
{section}
----
h3. Example
{code:javascript}
var smallHeader = fluid.jById(id);
var bigHeader = fluid.findAncestor(smallHeader, function (element) {
return $(element).is(selectors.sortHeader);
});
{code}
In this example, {{fluid.findAncestor()}} is used to find an ancestor of {{smallHeader}} that has a desired selector.
{div}