g(..).getSibling(dist, [n])

Retrieves a DOM element sibling of the nth element in the Gimme Object's internal array

Returns: The DOM element that is a sibling dist elements away (not including text nodes) from the nth element in the Gimme Object's internal array.
Params:
  • dist, required: A non-zero integer value (positive or negative) indicating the distance from the nth element in the Gimme Object's internal array.
  • n, optional (default = 0): An integer value between 0 and g(..).length - 1 inclusive, which specifies the index of the element whose sibling is to be retrieved.
Examples:
// retrieves the sibling directly preceding #main
var prev = g('#main').getSibling(-1);

// retrieves the 10th <li> element that follows the first <li> element under ul#nav (the 11th <li> element under ul#nav overall)
var farAway = g('ul#nav > li:first-child').getSibling(10);

Last edited Jun 20, 2007 at 6:41 AM by sstchur, version 3

Comments

No comments yet.