Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Include Pagedocs:sneak peek warningdocs:sneak peek warning
Div
classapi-page

fluid.findAncestor(element, test)

Section
Column
width70%

Finds the nearest ancestor of the element that passes the test.

Code Block
javascript
javascript
bgColorwhite
borderStylenone
fluid.findAncestor(element, test);

File name: Fluid.js

Parameters

Span
classborderless-table

element

(Element) DOM element

test

(Function) A function which takes an element as a parameter and returns true or false for some test.

Return Value

Span
classborderless-table

Element

the nearest ancestor that passes the test

Column
width5%

Column

See Also


Example

Code Block
javascript
javascript
var smallHeader = fluid.jById(id);
var bigHeader = fluid.findAncestor(smallHeader, function (element) {
    return $(element).is(selectors.sortHeader);
});

In this example, fluid.findAncestor() is used to find an ancestor of smallHeader that has a desired selector.