getNearest

jQuery.caph.focus.nearestFocusableFinderProvider.nearestFocusableFinder. getNearest

Gets the DOM element closest to the specific direction of the given element.

(static) getNearest(target, direction) → {DOMElement}

Parameters:
Name Type Description
target DOMElement | jQuery

The base element.

direction string

The direction to search for.

Returns:

If there is no nearest element, returns null.

Type
DOMElement
Example
function focusRight(from) {
		var controller = $.caph.focus.controllerProvider.getInstance();
 	var nearestFocusableFinder = $.caph.focus.nearestFocusableFinderProvider.getInstance();

		controller.focus(nearestFocusableFinder.getNearest(from, $.caph.focus.Constant.DIRECTION.RIGHT));
 }